Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

How to populate parent incident creation date on detection field in the incident form.

ashok17
Tera Contributor

How to populate parent incident creation date on 'detection field' in the incident form in the servicenow

 

I have tried below script on Business Rule but did not works for me. Please suggest achieve on this requirement.

 

(function executeRule(current, previous /*null when async*/ ) {
    if (current.parent_incident) {
        var parent = new GlideRecord('incident');
        if (parent.get(current.parent_incident)) {
            current.u_detection_time = parent.sys_created_on;
        }
    }
})(current, previous);
1 ACCEPTED SOLUTION

Tanushree Maiti
Kilo Patron

Hi @ashok17 

 

Try with getReference() method so that you can dot walk.

 

function onLoad() {   

 if (g_form.getValue('parent'))

{        

var parent = g_form.getReference('parent', function(parent) {

           g_form.setValue('u_detection_time', parent.sys_created_on);              

 });

   }

}

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

View solution in original post

5 REPLIES 5

namanajain
Kilo Guru

Hi @ashok17 
Please go through the below screenshot . I have also given the code below for the reference

Screenshot 2026-04-26 190630.png

Screenshot 2026-04-26 190640.png

Screenshot 2026-04-26 190730.png

 

Code:-  

(function executeRule(current, previous /*null when async*/) {

    // Only run if parent is set
    if (current.parent_incident.nil())
        return;

    // Optional: don't overwrite once populated
    // Remove this if you always want it to refresh
    if (!current.u_parent_created_date.nil() && !current.parent_incident.changes())
        return;

    var parent = new GlideRecord('incident');
    if (parent.get(current.parent_incident.toString())) {

        // Use getValue() to set the internal date-time value as a string
        current.u_parent_created_date = parent.getValue('sys_created_on');
    }

})(current, previous);
 
Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards

  

Hi @namanajain ,

Thanks for response and i tried below script on Business Rules and it's work for me:

 

 if (current.parent_incident) {
        var parent = new GlideRecord('incident');
        if (parent.get(current.parent_incident)) {
            current.u_detection_time = parent.sys_created_on;
        }
    }

Tanushree Maiti
Kilo Patron

Hi @ashok17 

 

Try with getReference() method so that you can dot walk.

 

function onLoad() {   

 if (g_form.getValue('parent'))

{        

var parent = g_form.getReference('parent', function(parent) {

           g_form.setValue('u_detection_time', parent.sys_created_on);              

 });

   }

}

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Hi @Tanushree Maiti ,

 

Thanks for response, I have tried below script on Business Rule and it's works.

 

 if (current.parent_incident) {
        var parent = new GlideRecord('incident');
        if (parent.get(current.parent_incident)) {
            current.u_detection_time = parent.sys_created_on;
        }
    }