Thank you @jaime.bosque , I was just looking up this post to figure out some new issues with program rules in the app. Will review that link and see if we can resolve them.
Do you know when the android and web will share the same rule engine?
My main issue is with the assign function, but I’m not assigning text, I’m assigning a numeric value that I then want to sum, not concatenate.
Rule 1 (priority 1)
Condition: #{occupation} ==5
Action: Assign value 3 to #{occupation_calculated}
Rule 2 (priority 1)
Condition: #{marital}==1
Action: Assign value 2 to #{marital_calculated}
Rule 3 (priority 2)
Condition: true
Action: Assign value #{occupation_calculated} + #{marital_calculated} to field “Final score”
In theory, if the user selects the option code 5 for occupation, it will assign a value of 3 to the calculated program variable, and then selects the option code 1 for marital status, it will assign a value of 2 to the calculated PV for marital status, and then the final score should be 5. This works fine on the web, but on the app (I think since 2.33.3), there’s no value. If you have a moment, let me know if you see anything off, thanks!
I am looking into this. I think there is a bug that has been included with the latest version of the RuleEngine… still trying to figure out but it seems that the Program Rule Variables cannot be used in the calculations.
However, I just tested that if you use directly the DataElements and not the PRV you will achieve what you want.
Rule 3 (priority 2)
Condition: true
Action: Assign value #{occupation} + #{marital} to field “Final score”
Will update here with further information, but just wanted to mention in case you are blocked somehow.
Regarding the alignment of RuleEngine between Web and Android I am not really sure. @marta, do you know maybe?
Thanks @jaime.bosque !
I think what you’re suggesting won’t work for calculating a score, unless the numeric value I want assigned to a certain option in an option set is the same as the code, right? Meaning, if I add the data elements themselves, am I not just adding up the option set codes (which are simply, 1, 2, 3, 4 and do not correspond to the “score” I want associated with each response)? I may not be understanding.
Thank you! Yes, apologies I wasn’t more clear that the issue is mainly where we are using option sets (or numeric values but where the “score value” differs from the code value).
@Natalie_Tibbels@jaime.bosque In my case I want to recode/convert ‘Male’ option to ‘1’. If option Male is selected then 1 will be assigned in another Track Entity Attribute. For this, I have created PRV
Could you try to change the TEA (Male Count Recode one) to a “text” value type. I’ve been testing in a 2.36 version and looks like there is an issue when you try to assign a value to a number/integer value type.
Big thanks @nancyesp. Now it’s working after changing value type integer to text. But one problem I get changing option does affect the program rule. Program rule evaluates same if change option Male to Female.
@arifazadkhan sorry to interfere but maybe it would be helpful if you share both program rules for Male and Female so it might be visible why you’re getting the same result? Thanks!
Also remember that when you change the option (if you first selected Male) then the value will remain but editable so you can erase it manually. In case you need to erase that value automatically, create another rule assigning “blank” or “0” to the TEA when you select “female”.