David Miller Posted November 23, 2011 Share Posted November 23, 2011 Is is possible to set a value for "Field X" based on user-choices for "Field Y" plus "Field Z" using JavaScript rules? Understand how to write a JavaScript rule that would return a specific value based on on multiple user-field values. But, want to set an "actual" field value. For Example: if ((Field("Field Y") == "A") && (Field("Field Z") == "B")) return 'A' + '_' + 'B'; //CAN --FIELD X-- BE SET TO THIS VALUE? -- NOT POSSIBLE? -- DON"T THINK SO--// The goal is to set a "hidden" iForms field value based on multiple user-field choices. It would be great to be able to do this via JavaScript rules. Not sure if it is possible. Thank you, -Dave Quote Link to comment Share on other sites More sharing options...
step Posted November 23, 2011 Share Posted November 23, 2011 Just trying to make sure I understand what you're trying to achieve: are you wanting to change the value of "Field X" to "A_B" given "Field Y" is "A" and "Field Z" is "B"? Or are you trying to change the value of "Field X" to whatever the value of "Field Y" and "Field Z" are, respectively, separating them by an underscore? I don't think that you can physically change the value of a field in your data. You could, however map the value of the two fields to a variable and return that instead: var FieldX = ""; if (Field("Field Y") == "A" && Field("Field Z")){ FieldX = "A_B"; } return FieldX; Quote Link to comment Share on other sites More sharing options...
David Miller Posted November 23, 2011 Author Share Posted November 23, 2011 Hi Step, You said, "...I don't think that you can physically change the value of a field in your data..." That is exactly what I was trying to ask. Didn't think so either. Thank you for confirming. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted November 23, 2011 Share Posted November 23, 2011 Is is possible to set a value for "Field X" based on user-choices for "Field Y" plus "Field Z" using JavaScript rules? Understand how to write a JavaScript rule that would return a specific value based on on multiple user-field values. But, want to set an "actual" field value. For Example: if ((Field("Field Y") == "A") && (Field("Field Z") == "B")) return 'A' + '_' + 'B'; //CAN --FIELD X-- BE SET TO THIS VALUE? -- NOT POSSIBLE? -- DON"T THINK SO--// The goal is to set a "hidden" iForms field value based on multiple user-field choices. It would be great to be able to do this via JavaScript rules. Not sure if it is possible. Thank you, -Dave If you name your rule "Field X", then whatever value it returned from that rule will be used for the "Field X" variable in your variable text frames, effectively overriding the value of any actual data field with the same name. Is that what you mean? Quote Link to comment Share on other sites More sharing options...
David Miller Posted November 23, 2011 Author Share Posted November 23, 2011 Yes. That is exactly what I mean. I will give it a try. Thank you. Quote Link to comment Share on other sites More sharing options...
step Posted November 28, 2011 Share Posted November 28, 2011 If you name your rule "Field X", then whatever value it returned from that rule will be used for the "Field X" variable in your variable text frames, effectively overriding the value of any actual data field with the same name. Right, but that's essentially the same as returning it as a global variable right? It's not going to actually rewrite the data file – if that's the intended goal. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted November 28, 2011 Share Posted November 28, 2011 (edited) Right, but that's essentially the same as returning it as a global variable right? No. A "global variable" implies a JavaScript variable, which can be accessed in a JavaScript rule, not a FusionPro text variable, which can be accessed directly in a text frame. These are two completely different things. Creating a rule with the same name as a data field does override the value of the data field when called out in a text frame (which creates a <variable name="***"> tag). However, calls to the JavaScript function Field() will always return the original data field value, and setting a global variable, or creating a rule, doesn't change this. But you can call the RuleOrField() function instead of Field() to apply any rule overrides in other rules. Or, if you do create a global variable, you can also reference that from other rules instead of calling Field(). It's not going to actually rewrite the data file – if that's the intended goal. Nothing described here actually rewrites the data file. The data file is an input file, by definition, so FusionPro doesn't modify it. But you don't want that anyway; you merely want to change how FusionPro handles the data in that file. Edited November 28, 2011 by Dan Korn fixed [quote] tags Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.