Flow approvals based upon a range of field values (number) taken from a MRVS

Dave105
Kilo Guru

Hi,

Hoping someone can assist with this, please? I have a catalog item that uses an MRVS (muli row variable set) to allow the customer to enter both a Quantity and individual Unit Price - this is then worked out into a third field of Total Price for each row. Once all rows have been completed there is a further field for Grand Total, the sum of all Total row fields, My  problem is that the business rule appears to be presenting the Grand Total as a string field and not a number, so the flow stages are not seeing this as a value and skipping all rules, i.e., if total is less than 5000 only 1 person needs to approve, else if total is between 5000 and 10000 then 2 people need to approve etc... 

I have tried the flow action "IF Condition "Catalog Variable > Grand Total > Convert String to Number" but that doesn't appear to resolve my problem, it still ignores my approval rules... 

 

My Business Rule:

Table: Requested Item

When to run: When Item > Purchase Request 

Script: 

(function executeRule(current, previous /*null when async*/ ) {

    var grMRVSAnswer = new GlideRecord('sc_multi_row_question_answer');
    grMRVSAnswer.addEncodedQuery('parent_id=' + current.getUniqueValue() + '^item_option_new=c4b49bccc3690a50464c3a0c05013138'); //SYSID of "Total" field in MRVS
    grMRVSAnswer.query();

    var totalInt = 0;
    while (grMRVSAnswer.next()) {
        if (grMRVSAnswer.value != '') {

            totalInt = parseInt(totalInt) + parseInt(grMRVSAnswer.value);
        }
    }

    current.variables.grand_total_before_vat = totalInt;
    //current.update();

})(current, previous);
 
My flow:
Dave105_0-1714113028804.png

 

If I have missed supplying any information that might assist in resolving my dilemma, please let me know... 

 

Regards

Dave

2 REPLIES 2

Vishwa Pandya19
Mega Sage

Hello,

 

Please check below discussion, it may be able to help you.

https://www.servicenow.com/community/developer-forum/unable-to-transform-string-to-number-with-flow-...

 

If my answer helps you in any way please mark it as correct or helpful.

Thanks for the link @Vishwa Pandya19,

I have not yet managed to translate the information into my own flow but will comeback to mark as accepted solution if this leads me to the solution.

 

Regards

Dave