Get MRVS variables in workflows Run script

Ankita9793
Tera Contributor

Hi all,

My requirement is to store MRVS Row data in below Sample object format in SCTask's

u_stp_payload field, MRVS has multiple rows and multiple tasks are getting created based on MRVS data. 

Sample Object :
{
                "RequesterUserId": current.opened_by,
                "RequestCategory": current.variables.request_category,
                "ServiceNowFormNumber": sctask.number,
                "ScTaskNumber": sctask.number,
                "AdminSystemName": current.variables.adminsystemname1,
                "CustomerNumber": current.variables.customernumber1,
                "KycRm": current.variables.kyc_rm1,
            },

Workflow RUN Script : 

var number = current.number;
var sysid = current.getUniqueValue();
var mrvsData = current.getValue("kyc_rm_update");
var mrvsDatastr = JSON.parse(mrvsData);

var reqitm = new GlideRecord('sc_req_item');
reqitm.addQuery('number', number);
reqitm.query();
while (reqitm.next()) {

    var sctask = new GlideRecord('sc_task');
    sctask.addEncodedQuery('request_item=' + reqitm.sys_id);
    sctask.query();
    while (sctask.next()) {

        var taskpara = [];
        for (var i = 0; i < mrvsDatastr.length; i++) {
           
            taskpara.push({
                "RequesterUserId": current.opened_by,
                "RequestCategory": current.variables.request_category,
                "ServiceNowFormNumber": sctask.number,
                "ScTaskNumber": sctask.number,
                "AdminSystemName": current.variables.adminsystemname1[i],
                "CustomerNumber": current.variables.customernumber1[i],
                "KycRm": current.variables.kyc_rm1[i],
            }, );

            sctask.u_stp_payload = JSON.stringify(taskpara);
            sctask.update();
        }
    }

}
Ankita9793_0-1748268616360.png

 

Ankita9793_1-1748268637176.png

 



1 REPLY 1

Swapna Abburi
Mega Sage
Mega Sage

Hi @Ankita9793 

Could you please confirm at what step this workflow script is configured in the workflow? Is it after catalog task creation workflow activity? if yes, you might have used "wait" checkbox in the task creation activity, until the task is completed, the run script activity may not get executed. 

 

You can see workflow execution and validate the step your above script is executing?