- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2022 11:03 AM
Hello,
I have a requirement to allow a user to select one of their previous RITMs from a reference field, and when selected, it will automatically populate the variables on the new RITM service portal form.
Example..a user had submitted a ticket for access to a shared drive, which was completed and closed. The access is only temporary and must be revalidated every so often. So when a user comes to the shared drive access form, if it is a request for revalidation, they can choose the previous RITM they submitted, and that would auto populate the variables on the form with the variables from the previous RITM.
I have a reference qualifier on the reference field to only show RITMs for the logged in user and for that particular cat item.
None of these variables are mapped to a field on a table. Just displayed in the variable editor
I have tried an onChange client script, but havent had any luck. Would a script include be required to achieve this? or can it be achieved with a glide query in an onchange client script?
var ritm = g_form.getValue('test'); //this is getting the value of what is selected in the reference field
var gr = new GlideRecord(sc_req_item);
gr.addQuery('sys_id', ritm);
gr.query();
while(gr.next() {
//how do i populate the variables on the current form with the variables from the selected RITM?
}
Please let me know if any other info is needed.
Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2022 11:21 AM
Hi,
You'd create an onChange client script that utilizes GlideAjax (script include) to communicate with the server and pass your reference field sys_id and query the table to get the record and then build an object of the variables you need to bring back to the client, then in the client, set the value for those fields with the same values you just retrieved.
GlideAjax cheat sheet (use an example to get you started): https://community.servicenow.com/community?id=community_article&sys_id=9f7ce2e1dbd0dbc01dcaf3231f961...
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2023 10:44 AM
@Bruler1230 Have you created a Catalo client script that is required to be attached in all catalog items for this copy functionality to work? I tried to write Server side scrip in widget to get previous RITM sys_id and get variables details and save into cart etc but unable to proceed further how to call again that newly saved RITM n screen so that user can edit and submit new one. My requirement is to use existing RITM to create new RITM where in user can change the varibale values and submit new RITM