Business App Owner and Managed By Cascade

Community Alums
Not applicable

I have a requirement to sync business app to mapped application service for the following fields owned_by and managed_by when the bus app owned_by and managed_by changes.   I am assuming it needs to be cmbd ci relationship table but not sure.  Any assistance is appreciated.

Thanks,

Chad

1 ACCEPTED SOLUTION

Hi @Community Alums 

On Which table this BR is written? Business Application or Relationship table.

 

It should be on business app table.

 

And add logs inside the if condition, so that we can be sure of the query returned results.

Thanks,
Anvesh

View solution in original post

5 REPLIES 5

Amit Gujarathi
Giga Sage
Giga Sage

HI @Community Alums ,
I trust you are doing great.
Here's a basic example of what the script might look like:

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

    // Query the cmdb_rel_ci table to find related Application Services
    var rel = new GlideRecord('cmdb_rel_ci');
    rel.addQuery('parent', current.sys_id); // Assuming current record is the Business Application
    rel.addQuery('child.sys_class_name', 'cmdb_ci_service'); // Filter for Application Services
    rel.query();

    while (rel.next()) {
        // Get the Application Service record
        var appService = new GlideRecord('cmdb_ci_service');
        if (appService.get(rel.child)) {
            // Update owned_by and managed_by fields
            appService.owned_by = current.owned_by;
            appService.managed_by = current.managed_by;
            appService.update();
        }
    }

})(current, previous);

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi