Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

i have created CI relationship using script with Scheduled job and Script Include , relationships are visible in cmdb_rel_ci table but the relationships are not reflected in Dependency Map for CI?

dasbiswa
Tera Expert

i have created CI relationship using script with Scheduled job and Script Include , relationships are visible in cmdb_rel_ci table but the relationships are not reflected in Dependency Map for CI?Please suggest me an option through which i can automatically create that using script

1 ACCEPTED SOLUTION

Have you tried using newRecord() instead of initialize()... they are different as newRecord() sets default values.

I also noticed there's a field called connection_strength which is set to always when I manually created the record. Try setting that in your script and let me know.

View solution in original post

6 REPLIES 6

Renato Perjes
Tera Contributor

I tried this -->

            var grRel = new GlideRecordSecure('cmdb_rel_ci');
            grRel.initialize();
            grRel.setValue('parent', target.getUniqueValue()); /* sys_id for the Parent CI
            grRel.setValue('type', relType); /* sys_id for the Relation
            grRel.setValue('child', grCi.getUniqueValue()); /* sys_id for the Child CI
            grRel.insert();
 
With background script, it creates the relationship and the relationship shows up in the dependency map view also. 
Tested on build: Washingtondc

Renato Perjes
Tera Contributor

I tested this -->

            var grRel = new GlideRecordSecure('cmdb_rel_ci');
            grRel.initialize();
            grRel.setValue('parent', target.getUniqueValue()); /* sys_id for the Parent CI
            grRel.setValue('type', relType); /* sys_id for the Relationship
            grRel.setValue('child', grCi.getUniqueValue()); /* sys_id for the Child CI
            grRel.insert();

In Background script, and it works as intended, now it creates the relationship and it also shows up in the dependency map view.
Tested on build: Washingtondc