Flow designer inline script to update an integer field with the sum of two other choice fields
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi, I really want to use a flow to set a field value. I could probably get this working easily as a business rule but at this point it's the principal of the thing. I have 2 choice fields with numeric values that, when updated, should be summed together and that result used to update an integer field. In the flow record I've plugged the script into an update record action using the following settings:
and my script content below:
(function execute(inputs, outputs) {
var gr = inputs.current;
// Get value of input fields and convert to integers
var benefit_value = gr.getValue('u_benefit');
var effort_value = gr.getValue('u_effort');
var benefit_number = parseInt(benefit_value, 10) || 0;
var effort_number = parseInt(effort_value, 10) || 0;
// Add values together
var score_value = benefit_number + effort_number;
// Set custom score and update record
gr.setValue('u_custom_score', score_value);
gr.update();
})(inputs, outputs);
When I try this, nothing happens, no error in the logs. Any ideas on how to get this to work without admitting defeat and going back to a BR?
0 REPLIES 0
