The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Get MRVS Value and update Asset table based on serial number using Workflow run script

Bijender
Tera Guru

Hi,
We created a MRVS < internal name : device_requests >. which contains two variables 
assigned_to : reference to sys_user table
serial_number: reference to alm_asset table

we want to update Asset table record based on serial number submitted using this MRVS.

tried creating a run script in Workflow, but it returns null value.

Bijender_0-1758121649373.png

 



var source_nameArr = [];
var mrvsData = JSON.parse(current.variables.device_requests); // 'my_mrvs_name'
var rowCount = mrvsData.getRowCount();
gs.info("FireFlow mvrsLength 1: " + rowCount);
for (var i = 0; i < rowCount; i++){
     var row = mrvsData.getRow(i);
     var variable1Value = row.variable1_serial_number; // actual internal name
     var variable2Value = row.variable2_assigned_to;
     workflow.info('Row ' + i + ': Var1=' + variable1Value + ', Var2=' + variable2Value);
}



1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Bijender 

try this

var source_nameArr = [];
var mrvsData = JSON.parse(current.variables.device_requests); // 'my_mrvs_name'

for (var i = 0; i < mrvsData.length; i++) {
    gs.info('serial number ' + mrvsData[i].serial_number);
    gs.info('assigned to ' + mrvsData[i].assigned_to);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Bijender 

update as this, it seems you are using wrong variable name

var variable1Value = row.serial_number; // actual internal name
var variable2Value = row.assigned_to;

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@Bijender 

try this

var source_nameArr = [];
var mrvsData = JSON.parse(current.variables.device_requests); // 'my_mrvs_name'

for (var i = 0; i < mrvsData.length; i++) {
    gs.info('serial number ' + mrvsData[i].serial_number);
    gs.info('assigned to ' + mrvsData[i].assigned_to);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader