- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 09:29 AM
Hello,
I need to set a value in a field (decimal) depending on the selection of a choice list field. I suppose this can be done with a business rule but can't make it to work.
The choice list field is 'size' and the choices in the list have the following values: small, medium, large, xlarge and xxlarge
The field to set the value is 'score_size'
The logic is:
Condition:
If 'size' changes
Action:
If size = small then score_size = 2
If size = mediumthen score_size = 4
If size = large then score_size = 6
If size = xlarge then score_size = 9
If size = xxlargethen score_size = 10
I created a condition stating
Need some help with the code and is this gonna be a before or after rule?
Thank you
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2017 05:56 AM
I managed to do it with an before business rule with the following code:
(function executeRule(current, previous /*null when async*/) {
current.score_size = current.size;
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 12:01 PM
This would be a ui script... and with the onChange.. so if one field changes the other one will change a also
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 12:15 PM
Hello Carlo,
I think a UI script won't work in my case because I forgot to mention that the field 'score_size' receiving the value is a hidden field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 12:15 PM
I believe you can use a client script and accomplish this without any code. Just set your condition to fit your needs.
If you want to use a business rule I think you would want it be before so the value changes and is then saved to the database. In your code set,
score_size = '0';
this will change the value for you.
Cheers,
Dylan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 12:17 PM
It doesn't have to be '0' either! It can be whatever the number is for that particular choice, hope this helps.
Dylan
