Retrieve RITM variables and use to populate it on the service portal form fields

ss123
Tera Contributor

Hi All,

 

We have this requirement to auto populate the portal form fields based on a RITM variables(same form)

What we need to do is that when a user selects an RITM number in "Original Request Number" field, we will retrieve the field values on that RITM and use it to auto populate in the portal form.

ss123_0-1724305840063.png

ss123_1-1724305977770.png

 

How can we achieve this? Thank you!

 

3 REPLIES 3

Murthy Ch
Giga Sage

Hello @ss123 

This post will help you.

 

Thanks,
Murthy

Rohit99
Mega Sage

Hi @ss123,

You can select field(to populate) in Auto-Populate section of Variables.
Attaching Screenshots.

 

Rohit99_0-1724309217420.png

 

 

Rohit99_1-1724309281441.png

 

 

 

Please mark my response as correct and helpful if it helped solved your question.

 

Thanks,

Rohit Suryawanshi

 

 

Ravi Gaurav
Giga Sage
Giga Sage

something like this should work :-

var ritmSysId = fd_data.trigger.ritm.sys_id;
var ritm = new GlideRecord('sc_req_item');
ritm.get(ritmSysId);
var arr = [];
var variables = ritm.variables.getElements();
for (var i = 0; i < variables.length; i++) {
    var question = variables[i].getQuestion();
    var label = question.getLabel();
    var value = question.getDisplayValue();
    if (label != '' && value != '') {
        arr.push(label + " - " + value);
    }
}
return arr.join('\n');
--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/