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

Arun Kumar D
Tera Contributor

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.

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);
}

 

Thanks in advance.

 

Best Regards,

Arun

1 REPLY 1

Brad Warman
Giga Sage

Hi @Arun Kumar D 

 

Instead of using regex to match the value, try the GlideURL API with the getParam method.

 

var url = new GlideURL(window.location.href);
var myParam = url.getParam('sys_myParameter');