Set Value on MVRS from the catalog form variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2024 03:24 AM
Hello All,
Thanks for looking into the ask,
We have a catalog variable : Applications(list collector)
We have a mvrs: which has Applications(reference) field.
We need to create and set, each row for the applications selected on the Catalog form variable Application(list collector) on to the MVRS.
Any feedback on the same will be highly appreciable.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 02:21 AM
Hello @Community Alums , thanks for the reply, we are able to map the list collector single value to one row, but multiple applications selected on MVRS is not adding extra row in MVRS.
The first row is only getting overridden.
if you could please check and help on the same.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 03:40 AM
Hi @Kaustubh k ,
The issue was with the array that was not storing the values properly.
Please find the below client script that will solve your issue.
function onLoad() {
var mrvsFieldName = 'mrvs'; // Name of your MRVS field
var listCollectorFieldName = 'applications'; // Name of your list collector field
var listCollectorValues = g_service_catalog.parent.getValue(listCollectorFieldName);
if (!listCollectorValues) return;
var selectedSysIds = listCollectorValues.split(',');
var mrvs = g_form.getValue(mrvsFieldName);
var mrvsData = mrvs ? JSON.parse(mrvs) : [];
selectedSysIds.forEach(function(sys_id) {
var ga = new GlideAjax('MRVSUtils');
ga.addParam('sysparm_name', 'getUserInfo');
ga.addParam('sysparm_id', sys_id);
ga.getXMLAnswer(function(response) {
var res = JSON.parse(response);
if (res.length > 0) {
var userInfo = res[0];
mrvsData.push({
'selected_friends': sys_id,
'user_name': userInfo.user_name,
'email': userInfo.email
});
g_form.setValue(mrvsFieldName, JSON.stringify(mrvsData));
}
});
});
}
If my response has resolved your query, please consider giving it a thumbs up and marking it as the correct answer!
Thanks & Regards,
Sanjay Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 10:49 PM
Hi @Kaustubh k
Below links could be helpful :
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.