How to look up a value in related list ?

ericlung
Tera Contributor

Hello ,

 

I am currently working on the "Change" from ITSM . Where I must fill the change request form with value from the Incident after I click on "Create Normal Change" but I cannot get the value of Incident in order to fill the change request form . I am currently working on the client script to solve it but cannot find the value from Incident .

 

The question I have is how to get the value of Incident record in the related list of change request. 

 

screenshot of the UI action that i use :

ericlung_0-1687718023884.png


example of form that I must fill with the Incident value:

ericlung_1-1687718062094.png

ericlung_2-1687718075024.png

 


screenshot of the client script :

ericlung_3-1687718144251.png


Code of the script :

function onLoad() {
    //Type appropriate comment here, and begin script below
    //Verify that the sys_id param is present in URL
    var gURL = new GlideURL();
    gURL.setFromCurrent();
    //var incidentID = gURL.getParam("sys_id");
    var incidentID = '2f61e18d87532950fe6162ce8bbb355a';
    alert("incidentID : " + incidentID);
	alert("get unique value : " + g_form.getUniqueValue());
	alert("change_request.incident.number : " + incident.number );

    while (gr.next()) {
        var sys_id = gr.getValue('sys_id');
        alert('sys_id: ' + sys_id);
    }

    var grcr = new GlideRecord('change_request');
    grcr.addQuery('related_link', 'incident.number');
    grcr.query();

    while (grcr.next()) {
        alert('Related link grcr : ' + grcr.sys_id + ' grcr.short_description : ' + grcr.short_description);
    }

    if (incidentID) {
        /**
		* 	Verified this request is a conversion from an Incident 
			Use the sys_id to create a new GlideRecord Objest with incident Data
	    */

        var grInc = new GlideRecord('incident');
        grInc.get(incidentID);

        // Map each of the Incident Fields to the relevant Request fields
        /**
         * 	Service -> Service
        	Service Offering -> Service Offering
        	Description - > Description
        	Assignment group ->Assignment group
        	Assignment to->Assignment to
        	Urgency -> Urgency
			impact -> impact
         */
        g_form.setValue('business_service', grInc.business_service);
        g_form.setValue('service_offering', grInc.service_offering);
        g_form.setValue('u_description_html', grInc.u_description_html);

    }

}
1 ACCEPTED SOLUTION

Harshal Aditya
Mega Sage
Mega Sage

Hi @ericlung ,

 

Hope you are doing well.

In such requirements I would prefer updating updating UI action - "Create Normal Change" or to create a BR.

 

As checked in your client script you have user GlideRecord it is not suggested to use that. If you still need to use client script please use GlideAjax

 

Please mark this response as correct or helpful if it assisted you with your question.

Regards,
Harshal

 

 

View solution in original post

1 REPLY 1

Harshal Aditya
Mega Sage
Mega Sage

Hi @ericlung ,

 

Hope you are doing well.

In such requirements I would prefer updating updating UI action - "Create Normal Change" or to create a BR.

 

As checked in your client script you have user GlideRecord it is not suggested to use that. If you still need to use client script please use GlideAjax

 

Please mark this response as correct or helpful if it assisted you with your question.

Regards,
Harshal