How to populate parent field on change while creating standard change from incident

Praneeth8
Tera Contributor

Hello Everyone,

I have created the standard change from the incident. but the parent field on the change form is not populated with incident sys id. I know there is an OOB UI action that calls OOB script include for standard change StdChangeUtils().getURLForTask(current, 'rfc') . This StdChangeUtils extends the OOB StdChangeUtilsSNC script include which is read-only. I am not sure where to edit the script to populate the parent field on the change form. can anyone suggest how to achieve this requirement?

9 REPLIES 9

adarsh-pand
Tera Contributor

Hello Everyone 

run it on after update and condition should be when Change Request is empty

 

(function executeRule(current, previous /*null when async*/ ) {
    var changeSysId = current.rfc;

    if (!changeSysId) {
        return;
    }


    var changeGR = new GlideRecord('change_request');
    if (changeGR.get(changeSysId)) {
        changeGR.parent = current.sys_id;
        changeGR.update();
    }

})(current, previous);
Apply this and if it helps mark as helpful...

Radha K
Giga Guru

Did you try writing the BR on change table - before insert? I see Mohit's script suggestion on incident table. But when we are creating the change request from incident table itself, I am not sure if udpate happens on incident.

No its on problem table 

Radha K
Giga Guru

The original question posted referes to change request being created from incident. Am I missing anything? Not sure where the problem table comes in action here? Please let me know if I wrong.

adarsh-pand
Tera Contributor

I know but there was same case with problem itself , write same BR on incident Table, (after update , change request is not empty ) Put that in condition and put the same script as above . It will work