Get MRVS value in Workflow

Ccart
Giga Expert

I am working in a workflow. I want to get fee_expiration  from a multi row variable set called hard_charge_fees. I am just checking to see if the value of fee_expiration is empty. How do I return all values of fee_expiration?

 

 

 

answer = ifScript();

function ifScript() {
    var feeExpValue = [];
    var mvrs = JSON.parse(current.variables.hard_charge_fees);

    workflow.info('feeExpValue:  mvrs: ' + JSON.stringify(current.variables.hard_charge_fees));

    for (var i = 0; i < mvrs.length; i++) {
        feeExpValue.push(mvrs[i].fee_expiration);
    }

    if ((feeExpValue != '') || (feeExpValue != 'undefined') || (feeExpValue != null)) {
        return 'yes';
    }
    return 'no';

}

 

 

 

 

 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

I'm not following why you would want to do this within an if activity, unless you want to return no if EVERY value of fee_expiration is empty in the MRVS.  In any event, this structure works best for retrieving and looping through an MRVS, with some logging to confirm the script is operating correctly:

answer = ifScript();

function ifScript() {
    var feeExpValue = [];
    var mvrs = current.variables.hard_charge_fees;
    var rowCount = mrvs.getRowCount();
    for(var i=0; i<rowCount; i++) {
        var row = mrvs.getRow(i);
        feeExpValue.push(row.fee_expiration.toString());
        workflow.info('fee_expiration:  mvrs: ' + row.fee_expiration);
    }
    workflow.info('feeExpValue: ' + feeExpValue.join(','));

    if ((feeExpValue != '') || (feeExpValue != 'undefined') || (feeExpValue != null)) {
        return 'yes';
    }
    return 'no';

}

 

View solution in original post

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

I'm not following why you would want to do this within an if activity, unless you want to return no if EVERY value of fee_expiration is empty in the MRVS.  In any event, this structure works best for retrieving and looping through an MRVS, with some logging to confirm the script is operating correctly:

answer = ifScript();

function ifScript() {
    var feeExpValue = [];
    var mvrs = current.variables.hard_charge_fees;
    var rowCount = mrvs.getRowCount();
    for(var i=0; i<rowCount; i++) {
        var row = mrvs.getRow(i);
        feeExpValue.push(row.fee_expiration.toString());
        workflow.info('fee_expiration:  mvrs: ' + row.fee_expiration);
    }
    workflow.info('feeExpValue: ' + feeExpValue.join(','));

    if ((feeExpValue != '') || (feeExpValue != 'undefined') || (feeExpValue != null)) {
        return 'yes';
    }
    return 'no';

}