Need help with a business rule to set a value in a field

kuarq
Mega Contributor

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

1 ACCEPTED SOLUTION

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);


View solution in original post

5 REPLIES 5

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);