Discovery Pattern Step-Create Relationship not happening

SNowUser11
Kilo Guru

Hello Experts,

I was looking to create relationship between a cmdb_ci_computer and cmdb_ci_service Using relation Depends On:: UsedBy

cmdb_ci_computer table contains a field u_service which is same as cmdb_ci_service table. Eg:

On Table cmdb_ci_computer

--------------------------------

Name                 u_service(String field) getting this via Discovery

COMPUTER1      Acrobat

 

On Table cmdb_ci_service 

-------------------------------

Name

Acrobat

 

Then on Table 'cmdb_rel_ci' want to create a relation

Parent             Type                            Child

Acrobat            Depends On::UsedBy     COMPUTER1

It does not give me error but does not create result when i do TEST . Any step I am missing please guide.  Thanks

find_real_file.png

 

30 REPLIES 30

Please suggest any idea what wrong in here script

Can you look if that should work please

SiD2
ServiceNow Employee
ServiceNow Employee

Hi @SNowUser11,

There is an issue with your script logic.

You need to have the sys ids of the records for which you need to create a relation. But I see you are passing GlideRecord object for Service and name for Computer CI.

For Service CI, post querying that you can do a getUniqueValue on the GlideRecord object which will give you the sys id of the service record you queried.

For computer CI, the sys id of the server record will be available in payload, so you can access that using payloaditems[i].values.sys_id and pass that.

 

Apart from these, I assume you have configured your new post sensor script to run for your server pattern.

In discovery status log, if you click on the pattern log, in left side menu, it will show the pattern and steps that are executed, similarly it will show the post sensor script name that got executed.

Let me know if you have any queries.

 

Please mark the appropriate responses as Correct/Helpful so that this thread gets closed and helps others with the same question in the future.

Please mark Helpful / Accept Solution so that it helps others with similar questions.

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi @SNowUser11 ,


There is one more thing which should be considered is suggested relationships on this CI class and the containment or hosting rules.

 

Discover does make use of suggested relationships to create relationships. If this is a custom pattern or section then you should also make sure that the details are in place because IDR enginee will make use of this in post processing of the pattern.


Thanks,
Ashutosh

Hi Ashutosh,

so as OOB there is already the relationship (depends on:: used by) for cmdb_ci_service and cmdb_ci_computer and I am trying to create the same relation. But yes its true that the value of Service which I am fetching via discovery is inserted in cmdb_ci_computer and rather NOT in cmdb_ci_service. SO thinking that if we can somehow compare that the value what we are getting is existing in cmdb_ci_service table then make a relationship.

Please let me know everyone's expertise knowledge on this as I am not sure if that is my correct understanding 

Thanks