Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to auto populate incident number on a change request when change is created from Incident

nbkxx5i
Giga Contributor

how to auto populate incident number on a change request when change is created from Incident

2 REPLIES 2

Cheikh Ahmadou
Kilo Sage

-> 1st option: Try to look at this Business Rule first: "Link change to task record" 
-> 2nd option: Create a Business Rule on Change Request
1. Trigger: When a change is created from an Incident
2. Table: Change Request [change_request]
3. When: before
4. Insert: true
5. Update: false
6. Filter condition: current.u_incident_reference.nil() && current.operation() == 'insert'
7. Example of script:

(function executeRule(current, gSNC, gs) {
    var incidentSysId = gs.getSession().getProperty('change_link');

   if (incidentSysId) {
     current.u_incident_reference = incidentSysId;
    }
})();



NB: getProperty('change_link') should return an object containing tablename, record id, ...

palanikumar
Giga Sage
Giga Sage

Are you creating Change using any UI Action or via script?

If using UI Action, do you use the OOTB UI Action to create Change or created custom one?

Thank you,
Palani