Need to Auto-Populate Incident Number in RITM Field from Parent Incident

Naveen87
Tera Guru

Hello Developers,

 

I have a requirement where an RITM is created from an Incident using the 'Relates Search Results' functionality. From there, users can search for a Service Requester and click on ‘Order’, which redirects them to the catalog item using the servicecatalog_cat_item_view form.

In this context, I’d like to auto-populate the field what_is_source_of_exception_requirement on the catalog item with the incident number (i.e., the parent record of the RITM).

 

Here’s the URL being used:

com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=8ea574d297a62290cbf4b976f053af12&sysparm_view=catalog_default&sysparm_parent_table=incident&sysparm_parent_sys_id=096777069726ee50cbf4b976f053af57

 

I attempted this via a client script, but it doesn’t seem to work—likely because client scripts can’t access server-side data like the incident number directly using GlideRecord.

Could you please advise if this can be achieved, and if so, what would be the recommended approach?

 

Thank you!

 

Naveen87_0-1751898981585.png

 

Naveen87_1-1751899039800.png

 

Naveen87_2-1751899226710.png

 

 

 

1 ACCEPTED SOLUTION

@Naveen87 

I already informed to use GlideAjax and query INC table and get number

Another way is to use GlideRecord with callback

Something like this

function onLoad() {

    var gUrl = new GlideURL();
    gUrl.setFromCurrent();
    var incSysId = gUrl.getParam("sysparm_parent_sys_id");

    var gr = new GlideRecord('incident');
    gr.addQuery('sys_id', incSysId);
    gr.query(checkRecord);

    function checkRecord(gr) {
        if (gr.next()) {
            g_form.setValue('what_is_source_of_exception_requirement', gr.number);
        }
    }

}

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

@Naveen87 

GlideRecord with callback should be fine.

Another way I already told to use GlideAjax

I believe I have answered your question.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader