The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Create Standard Change from RITM and set Change parent as RITM reference

arundharmabe
Tera Guru

Hello Everyone,

 

I'm having a requirement to Create Standard Change from RITM and set Change parent as RITM reference.

I did created below UI action which takes me to the standard change templates landing page,

var url = new StdChangeUtils().getURLForTask(current, 'rfc');
url += '&ritm_sys_id=' + current.sys_id;
action.setRedirectURL(url);

 

In this script, i am injecting ritm_sys_id into the URL and trying extract it & populate the parent field on the change form with the RITM reference.

However the below onLoad client script is not working as expected. Any suggestion/advice are welcome.

 

Below is the client script i am using to parse the URL,

if (!gForm.isNewRecord()) return;

try {
var fullUrl = window.location.href;

var match = fullUrl.match(/[?&]ritm_sys_id=([0-9a-f]{32})/);
if (match && match[1]) {
var ritmSysId = match[1];
gForm.setValue('parent', ritmSysId);
}
} catch (e) {
console.error('Error extracting ritm_sys_id:', e);
}

 

Has anyone implemented any similar solution, show some light on this.

 

Thanks 

Arun

1 REPLY 1

Laveena-Agarwal
Kilo Sage

Hi @arundharmabe 

Check this post - Solved: How to Create Standard Change from RITM and relate... - ServiceNow Community

You just need to scroll a little bit to see the script provided by Author.