Get MRVS variables in workflows Run script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 07:09 AM - edited 05-26-2025 07:10 AM
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 :
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 :
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();
}
}
}


1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 07:31 AM
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?