Hello,
I have created a macro that distributes a chosen value across rows according to chosen weight and group fields to be used as a custom tool for my team. The macro works great, but I am running into one very perplexing issue. I am attempting to update the Raw XML of a formula tool using an Action tool (see attached Macro Screenshot file). However, for some reason that I have been unable to solve, this step fails when the chosen Weight and/or Value field contains a space in the field name.
For example, if the user chooses a field called "Dollars" and "DaysAvailable" (no spaces) as the Value and Weight fields, the macro runs successfully. However, if the user chooses a field called "Revenue Dollars" or "Days Available" (with spaces) as the Value and/or Weight fields, the action tool seems to only detect the first word of the chosen field and therefore fails and produces the following error messages:
Parse Error at char(0): Unknown variable "Days" (Expression #1)
and Parse Error at char(0): Unknown variable "Revenue" (Expression #2)
The Action tool inputs are set to the following:
[#1] = User-Chosen Weight Field
[#2] = User-Chosen Value Field
It is currently updating the raw XML of the formula tool with the following:
if [#1] = '' then
'<FormulaField expression="1" field="Weight_Chosen" size="8" type="Double" />'
else
'<FormulaField expression="'+[#1]+'" field="Weight_Chosen" size="8" type="Double" />'
endif
+
if [#2] = '' then
'<FormulaField expression="0" field="Value_Chosen" size="8" type="Double" />'
else
'<FormulaField expression="'+[#2]+'" field="Value_Chosen" size="8" type="Double" />'
endif
Is my XML formula somehow restricting the Weight and Value fields to the first word in a field name? Suggestions to correct this would be very much appreciated!
See attached for the files.
Thanks in advance!