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

Chuck Tomasi
Tera Patron

Can you include a sample of the code and the results?

 

Tip: Ensure you are using relationship entries from cmdb_rel_type when you create the relationship.

dasbiswa
Tera Expert

Hi Chuck,

Yes i am inserting records in cmdb_rel_ci  with type taken from cmdb_rel_type which resulted in CI relationship getting inserted but no effect in dependency view.

Could you also please let me know where those entries rae made when we manually create Dependency Map by clicking Add CI relationship Ui Action.

Please find the sample code.

var CIDR;
var gr = new GlideRecord('cmdb_ci_win_server');
gr.query();
while(gr.next())
{
CIDR = gr.u_inside_subnet_cidr; // referenc field returning sys_id

var grIn = new GlideRecord('cmdb_rel_ci');
grIn.initialize();
grIn.parent = CIDR;
grIn.child = gr.sys_id;
grIn.type = 'dc1f1f88db7193809020735a8c961966'; // sys_id of the Relationship Type
grIn.insert();
}

Thanks

Biswajyoti

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.

kranthi
Tera Contributor

Hello Biswa,

I am looking for the same solution, can you please let me know if you have the script to create relatioship.

Thanks,

kranthi.