I'm working on a form that creates a wide range of conditional statements that build from one another over time. To do this, I made a single large table with a range of user-filled options. For the problem cell, I've got a set of if-else statements with five potential outcomes, which are themselves dependent upon another variable from a prior cell. The conditional is as follows:
var StW2;
if(GeneralTable.Row1.CollarType.rawValue == "Option 1" && Ero == 1 && RDB46BPF.rawValue >= 96.75 && RDB46BPF.rawValue <= 108.75)
{StW2 = 0}
else if(GeneralTable.Row1.CollarType.rawValue == "Option 2" && Ero == 1 && RDB46BPF.rawValue >= 83 && RDB46BPF.rawValue <= 96.75)
{StW2 = 1}
else if(GeneralTable.Row1.CollarType.rawValue == "Option 3" && Ero == 1 && RDB46BPF.rawValue < 83 && RDB46BPF.rawValue > 60.75)
{StW2 = 2}
else if(GeneralTable.Row1.CollarType.rawValue == "Option 4" && (Ero == 1 && RDB46BPF.rawValue < 60.75) || (Ero == 0 && this.rawValue > 22))
{StW2 = 3}
else{StW2 = 4;};
As a test to validate the statement is working, I add this just below the statement so that I can see what StW2's value is in action:
xfa.resolveNode("Row2[9].RDB46CPF").rawValue = StW2;
I've not been able to get any value at all, which must mean there's something wrong with my overall conditional formula, but after several hours of testing and making minute changes and testing again and reviewing these forums, I can't figure out what I'm doing wrong.
A few things of note:
At the moment I can only think of two possibilities: either there's something wrong with the AND and OR statements' formatting for Option 4, or the cell is not pulling the value of Ero because it was created and defined in a separate cell. If anyone has any insights that might help me out, I'd appreciate it.
Solved! Go to Solution.
Views
Replies
Total Likes
Okay, I'll try to make it simple for you to understand...
First of all, to assign a value to a text field you must use the '=' operator as follows :
To compare values you must use the '==' or '===' operators, both have different behaviour but '==' is the most commonly used.
Now to assign a value to a text field, you must use the rawValue property and the '=' operator and to pull the value from the text field use the rawValue property as well.
So technically in the event which you declare the variable Ero, you should assign the value Ero within the text field.
Once you want to access that value from another event, just make sure to use the right reference syntax to access that text field you have assigned the value in, and pull the value using rawValue property... You can also re-declare the variable Ero in that other event directly to be the rawValue of the hidden text field. See example below :
I hope this will help you to get on the right track.
Views
Replies
Total Likes
Hi there,
Without going any further, if Ero is declared somewhere else than the event itself, you found your problem.
Either you have a hidden field that can hold that value for other events or you create that variable within a script object and create a get set function.
If this does not work, then you probably have something else to fix.
Hope this will help.
Views
Replies
Total Likes
Hey, Magus, thanks for the help. After reading up on the topic of Get Set functions and Script Objects and doing some experimentation, I'm afraid I'm still no closer to a solution. This is almost certainly because I don't understand get how to call upon and change the object value using a get/set function.
I suppose I don't have to use variables to do the intended work, but I would like to learn them anyway to expand upon my LiveCycle knowledge. Is there somewhere I can go to get an in-detail example/ lesson on how to get and change script object variable values through JavaScript at any place in the form I need?
Views
Replies
Total Likes
In this case it would be simpler to store your value in a hidden textfield.
Either one or the other is good, get set functions are only easy access troughout the whole form and might be of a better use when having many different variables to handle. Usually get set functions are for oriented objects... which is not your case. It was only an option.
Go for the hidden text field, sorry for the confusion.
Views
Replies
Total Likes
Apologies, but I remain confused. While I can make a hidden text field easily enough and create variables within it, the primary problem remains: I don't know how to pull the variable values from that hidden text field (or a script object if I were to use that option) for use/changing in other fields. I had hoped it would be as simple as using "==" and "=" comparisons, but clearly that is not the case, and my help files only refer to variables in terms of script objects (and then without telling me how to use them as I intend to).
Please understand, I'm not the most deeply versed in LiveCycle or Javascript. The most knowledge I have regarding variables is how to declare them and use them within a single event. I've scoured a range of sources trying to find out how this works and have come up empty. Apparently it's supposed to be so simple that nobody's bothered to describe the process. Or I just don't know where to look.
Views
Replies
Total Likes
Okay, I'll try to make it simple for you to understand...
First of all, to assign a value to a text field you must use the '=' operator as follows :
To compare values you must use the '==' or '===' operators, both have different behaviour but '==' is the most commonly used.
Now to assign a value to a text field, you must use the rawValue property and the '=' operator and to pull the value from the text field use the rawValue property as well.
So technically in the event which you declare the variable Ero, you should assign the value Ero within the text field.
Once you want to access that value from another event, just make sure to use the right reference syntax to access that text field you have assigned the value in, and pull the value using rawValue property... You can also re-declare the variable Ero in that other event directly to be the rawValue of the hidden text field. See example below :
I hope this will help you to get on the right track.
Views
Replies
Total Likes
Oh... OH. All this time I was trying to get the script-defined variables! I had no idea we were talking about pulling rawValues. I do that all the time and it should have been obvious.
On the one hand, this does fly in the face of the original reason I was doing all of this in the first place. That original intention was to create a set of formulae based on variables instead of pulling the long codes of rawValues, hopefully making it easier to follow for whoever comes after me in three or four years to update the form. This method pulls the rawValues, which is exactly what I was trying to avoid.
But if it works, it works. I will make use of this method. Thanks, this solves the problem in its entirety!
Views
Replies
Total Likes