MRVS value in RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2025 04:49 AM
Hi,
I have a MRVS in my catalog which displays asset name and serial number of user selected as Requested for field on field.
The structure of my catalog is:
1. Requested for field (List collector type) {independent of variable set}
2. Request for, Machine Name, Serial Number as 3 variables in MRVS.
Based on users selected in 1., 3 variables are gettting auto populated on the form.
On submit of request, multiple RITMs are getting generated under one request based on number of users selected in point 1. The variables (except MRVS) are getting copied as well in all the ritms. However, MRVS is not getting copied. It is empty.
I want in each RITM, respective user records from point 2 should only be displayed.
I realised for MRVS , values are empty in sc_item_option_mtom table. and MRVS values are stored in Multi Row Question Answer [sc_multi_row_question_answer] table.
How do i display MRVS values specific to user in each RITMs individually ?
Below is my current code that i have writen in workflow script. This script basically creates multiple ritms and copies variables and values from parent RITM.
var list = current.variables.requested_for.toString(); //users selected in point 1
var array = list.split(',');
var request = current.request;
var catalogItem = '008cb57d83562ad0618ccc40ceaad37f';
var usrID = '';
var usrName = '';
for (var i = 1; i < array.length; i++) {
var grUserDetails = new GlideRecord('sys_user');
grUserDetails.addQuery('sys_id', array[i]);
grUserDetails.query();
if (grUserDetails.next()) {
usrID = grUserDetails.user_name;
usrName = grUserDetails.name;
}
var grRitm = new GlideRecord("sc_req_item");
grRitm.initialize();
grRitm.cat_item = catalogItem;
grRitm.request = request;
grRitm.requested_for = array[i]; //requested for
grRitm.user_name = usrID; //user id
grRitm.short_description = "Test request for " + usrName;
var ritmSysId = grRitm.insert();
var ritmVar = new GlideRecord('sc_item_option_mtom');
ritmVar.addQuery('request_item', current.getUniqueValue());
ritmVar.orderBy('sc_item_option.order');
ritmVar.query();
while (ritmVar.next()) {
var chgVar = new GlideRecord('sc_item_option_mtom');
chgVar.initialize();
chgVar.request_item = ritmSysId;
chgVar.sc_item_option = ritmVar.sc_item_option;
var opid = chgVar.insert();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2025 07:15 AM
Ruchi,
You need to do similar code for the MRVS. You would need to collect the values from the MRVS into an array or I guess you could query for them as you go through the code...but think creating an array is the better option. Then when you are on the first new RITM, you need to get the values from the first row from the array and create those entries, then when you do the second RITM you need to access the second row in the array and apply, etc. I had done something similar in the past where I was using a count but probably better to use the row index to know which record you are working with.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 02:06 AM
you should use Cart API or CartJS to create the child RITMs and don't use GlideRecord.
Remember you can't set MRVS using CartAPI or CartJS
You can update the RITM with MRVS after it gets created.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2025 11:56 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader