How to access nic and nic.cmdb_ci field values using After BR?

venkat101
Tera Guru

Hi,

I want to create relationship record between ip address and network table after discovery is completed. So, I wrote an after insert BR rule on ip address table and create a relationship record. Before creating relationship record i want to verify if current.ip_address is same as ip address on its discovered CI. so, i am trying to get nic and nic.cmdb_ci field values from ip address record and i am failing capture them.

 

gs.info('current IP record nic: ' + current.name+ ' ' + current.nic);
i was able to see current.name value as "170.10.1.10" but nothing for current.nic, can you please help in suggesting the best way to capture nic and its associated ci details to the work i want to do?
7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@venkat101 

BR is on which table?

share some screenshots

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

BR is written on ip address table.

I have not written whole code. Currently i am looking for ways to implement it. So open for ideas. I thought i can do it through after insert BR. and i am stuck with basic log statement i wrote in description. I want to know what all fields i can access through "current" object and then write the logic.

Adding the code i wrote:

(function executeRule(current, previous /*null when async*/) {
   
    var discUtils = new DiscoveryAutomationUtils();
   
    if(current.operation() == "insert" && current.install_status == 1 && current.ip_address == current.nic.cmdb_ci.ip_address) {
        insertCIRelation();
    }}

@venkat101 

 

When you create a business rule on table, it becomes the current object. For example, if BR is on ip_address table, current.ip_address_field would give value of current record for which BR is executing.

 

Take for example below BR on cmdb_ci table, current.<any cmdb_ci table fields> or current.<dot-walked fields of cmdb_ci table> can be used for current object. If you want to compare field values of current table with another table fields, you need to use glide record class and compare current object field(s) with glide record field(s).

 

Bhuvan_0-1757397756980.png

If this helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan