- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2023 04:02 AM
HI,
i have created a catalog item and user MRVS in that, there are 2 fields in multi row
request_type = action and deletion
association = Non government and government
Now i want a condition to check if request type is action or deletion && association is No government then its Yes otherwise No
I tried to write MRVS script but not working
Multi row variable set internal name: declaration_list
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2023 06:47 AM
you didn't answer my above question
are you saying if any 1 row satisfies that condition then you want to return yes or all rows should satisfy that condition?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2023 04:16 AM
Hello Karan,
We can use like that in the workflow script -
current.variables.multi_row_variablename.getRowCount() for getting length of array and getRow() for accessing the data of a array.
Please refer below link for better understanding -
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0743684
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2023 04:22 AM - edited ‎05-15-2023 04:29 AM
If possible can you share the script
below is example how we use for normal variable
answer = ifScript();
function ifScript() {
if (current.variables.declaration_type == 'Gift' || current.variables.declaration_type == 'Hospitality' && current.variables.associate == 'Non Government Official') {
return 'yes';
} else {
return 'no';
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2023 04:28 AM - edited ‎05-15-2023 04:30 AM
It would be like -
// Syntax for this is gr.variables.table_var.getRow(<ROW NUMBER [i]>) which returns ith row from the multi row variable
// and we are trying to access a cell out of it as below
var row = gr.variables.multirowVariablName.getRow('1');
gs.log( "Fetching Row 1 "+ row.declaration_type);
You can go through the above link.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2023 04:58 AM
Suppose you have a multi-row variable with the named as "server_build_list" and defined with the following fields [with data type]:
- u_data_center - String
- u_how_many - Integer
- u_storage_size - String
then you can use script as -
var rowLength = current.variables.server_build_list.getRowCount();
for(var i=0;i<rowLength;i++){
var row = current.variables.server_build_list.getRow(i);
var dataCenter = row.u_data_center;
var storageSize = row.u_storage_size
}