Retrieve Multirow variable set values from a closed RITM

Nagashree5
Tera Contributor

Hi All,

 

I have built a new table(Service Desk Case) which is extended from task table and have created a record producer on it.

So, on the record producer, there is a field called closed cases which shows only closed cases in a drop-down, on selection of a request, the form fields needs to be filled with the closed Case variable values. I'm able to retrieve all the variable values and populate it on the form level, but there is a MVRS as well, how do I retrieve the values of a MVRS and set the form level field with the same values, Please share any ideas on this. Below is the script I'm using to retrieve the variable values and populate it on the form level.

Script Include:

testing: function() {
var ritmnum = this.getParameter('sysparm_company');

var gr = new GlideRecord('sd_case');
gr.addQuery('number', ritmnum);
gr.query();
while (gr.next()) {
var gbsobj = {};
gbsobj.saptype = gr.variables.sap_type.getDisplayValue();

gbsobj.cur = gr.variables.currency.toString();
return (global.JSON.stringify(gbsobj));
} },

type: 'testvariablesg'
});

Client Script:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('testvariablesg');
ga.addParam('sysparm_name', 'testing');
var com = g_form.getDisplayValue('latest_ritm');
//alert(com);
ga.addParam('sysparm_company', com);
ga.getXML(callBackFunction);

function callBackFunction(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer); {
answer = JSON.parse(answer);
g_form.setValue('currency', answer.cur);
g_form.setValue('sap_cost_type', answer.sapcosty);

}}}

The above is working fine to retreive the variable values and populate it on the form level, but how do I retrieve the MVRS values. Please share any ideas on this.

Thank you in Advance.

4 REPLIES 4

Pavankumar_1
Mega Patron

Hi @Nagashree5 ,

 refer below article to get the mrvs values.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0743684

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Maybe this helps:
- 2021-05-20 - Article - Creating records or a summary from Multi-Row Variable Set (2)

 

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Pavankumar_1
Mega Patron

Hi @Nagashree5 ,

If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.

Or reply if you have any issues.

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

KBKennedy
Tera Contributor

I know this is an old post, but I recently came across it looking for a solution to this. I never found it on here, but I was able to get it working and so I wanted to share my solution.

 

https://www.servicenow.com/community/virtual-agent-forum/populate-mrvs-with-values-retrieved-from-pr...