Use PDIs? Take our 5-minute survey to help shape the PDI roadmap.

Auto-Populate a reference field of parent table with the name of the Child

Chandrika4
Tera Contributor

Hi Team,

 

Can you please guide me regarding the After Business Rule to Auto populate a custom field named as"Physical Host Name" on a Parent Server record with the Child name once a CI Relationship is created. 

Below is my sample script: 

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

    // Add your code here
    var gr = new GlideRecord(current.getRecordClassName());
    if (gr.get(current.parent)) {
        if (!gr.u_physical_host_name) {
            gr.u_physical_host_name = current.child;
            gr.update();
        }
    }

})(current, previous);
9 REPLIES 9

glideFather
Tera Patron

ahoy @Chandrika4,

 

have you tried to log your BR? The field that you plan to populate is it a string, reference or what type? And same for the parent, are they 1:1?

 

Then it will might require different approach based on the data types...

 

What you can do is to try this behaviour in a background script and once you manage to update it on one selected record then you can apply on the BR level.


✂-----Cutting-out-the---✦AI-noise✦---All-replies-written-and-vouched-for-by-GlideFather---

Hi,

 

It is a reference field to CI table. I have tried putting logs, it seems the BR is not triggering at all. 

ahoy @Chandrika4,

 

well, could you possibly share that business rule?

 

Eventually you can remove the trigger (to be executed always), then you migth see if the script is working or not. If it works then you have an incorrect trigger, if it doesn't work either, it's not the trigger...

 

What you shared is not sufficient to help you, provide more details


✂-----Cutting-out-the---✦AI-noise✦---All-replies-written-and-vouched-for-by-GlideFather---

@glideFather ,

1000048587.jpg

 I have already shared the script. Please suggest.