Sohail Khilji
Kilo Patron
Kilo Patron

How to pass any Discovery Schedule fields to a CI record via Discovery

 

QUESTION : DID YOU READ ALL MY DISCOVERY ARTICLES ? But, Do it later....

 

I rescently has to populate 270,000 CIs Support Group / Assignment Groups from discovery... All our existing Discovery schedules were based on Device types like Windows discovery Schedule, Linux Discovery Schedule, CISCO Discovery schedule etc... Hence discovery schedule are  created based on device type as there are no other discovery sources which updates CMDB.

 

png-transparent-sad-angry-man-face-annoyed-mad-emotion-expression-thumbnail.png

Its hard in my current environment to establish a communication with diffrent team and requesting to update the support group/assignment group. There were no logical critera do define bussiness rule / flows to determine support group for each device.

 

Are you facing similar issue or you wanted to populate certain field from Discovery Schedule to CMDB CI record ? Yes i have a working solution for you here... 

 

Solution :

I decied to create a Custom field on Discovery schedule table named as 'DEEMS Support Group' this filed will consist of support group which is responsible for the IPs/Subnets Which are there in this discovery schedule that runs weekly. (dedicated discovery schedule for each team)

 

Lets say a support group called 'Automation team'  > This team own 5 VMs , 20Wins servers , 6 Linux servers. I have create a discovery schedule for Automation Team as "DEEMS-Automation_Team Devices"" which has IPs and Subnets of all VMs, Win Server, Linux server in 1 schedule owned by them.

 

So, I would update the custom field with the value of their team name as > "DEEMS -Automation_Team Devices" , so when the discovery run and discovers new CIs or Updates existing CI the value of custom field will be copied to CMDB CI field ''Support Group'' OR ''Assignment Group''. Hence you will be having / setting Support group / Assignment group for all CIs discovered via Servicenow Discovery.

 

So lets see how did i do it ?

main-qimg-e860e50351d89bdfc08cbdcad0977124-lq.jpg

Step 1 : 

First, Navigate to script include  > search for *Discovery Schedule. Ull end up with below script include as shown in image.

Here you need to add a new variable as i have added for 'u_deem_support_group' (this is the custom field is which i wanted to copy it to the CI record.) 

 

 

this.support_group = gr.getValue('u_deem_support_group'); //Replace 'u_deem_support_group' with your field value (in my case its a reference field)

 

 

SohailKhilji_0-1713963793183.png

 

Step 2 : 

Now , You have obtained and stored the valued of the customfield in to a varaible called this.support_group in discovery schedule script include.

 

Navigate to > Sensor > Shazzam. 

 

This is the script which will update the customfiled value in to the CMDB CI record. 

Move to line > 103 (may change in future) , under which you need to call a function . in my case i created a function name called this.updateSupportGroup(); , Hence youcan include include the function call here at line > 105 (may change in future).

 

 

SohailKhilji_1-1713944731549.png

 

Step 3:

On the same script create function called updateSupportGroup();, So Move to line 699 (May change in Future) and create a new function which actually copies the value of a field from discovery schedule record to discovered  CI record.

 

 

 

updateSupportGroup: function() {
if (!this.schedule.support_group) // here support group indicates the value which you have set in step 1 , for the variable this.schedule.support_group
return;
this.ciData.getData()['support_group'] = this.schedule.support_group;  // here support_group indicates the cmdb_ci table field
},

 

 

 

(Read the comments on the above script)

SohailKhilji_0-1713944731543.png

 

Step 4:

Save the record and run the discovery Schedule, Once the schedule is completed Check the CI which is updated / created you would see the support group/assignment group getting updated from discovery.

 

Also Read : 

Set Discovery Schedule name to CMDB Record (via Discovery) 

 https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0820001

 

Feel free to comment below the errors / issues / quries that you face and ill be happy to help !

 

If you find the article to be useful or effective for your knowledge Kindly Consider Marking the article HELPFUL and BOOKMARK if for your future use...

 

 

< Previous Post                                                          Next Post >

 

           <<<  Top Articles  >>>

  1. ServiceNow Integration with Splunk
  2. LDAP Integration with ServiceNow
  3. ServiceNow Integration with Veeam
  4. Handling ServiceNow flow errors with a flow
  5. Show parent child incident relationships - display in field message
  6. ServiceNow SSO Logout Error (redirects to logout page) – Reason, Fixes and Cause.
  7. Multi Row Variable set ServiceNow MRVS - Creating - Scripting - Example - Limits
  8. ServiceNow Integration with MAC vendor - Get Mac vendor for the given MAC Address.
  9. How to find Log4j vulnerable severs in ServiceNow Using CMDB Query Builder (SecOps) 
  10. How to Cancel a Long-Running Transaction ServiceNow
  11. Hidden Features for System Administrators
  12. Servicenow RPA - Understanding Attended / Unattended / Skilled Automation Bots
  13. Servicenow vCenter Discovery | Step by step Discovering VMware using vCenter Discovery. 
  14. Set Discovery Schedule name to CMDB Record (via Discovery) 
  15. Step by Step - How to discover Linux Servers in ServiceNow 
  16. How to Generate PDF from UI action. 
  17. Servicenow Discovery Implementaion Requirement Gathering & Pre-requisites.

 

 

SohailKhilji_1-1713966056790.jpeg

 

 

MF Sohail Khilji | Servicenow Developer /  Consultant.

Connect On LinkedIn >   https://www.linkedin.com/in/mf-sohail-khilji/

 

#Discovery #ITOM #Servicenow 

 

 

 

Comments
piotrkopytynski
Tera Contributor

It's not that I don't like it but you can do a similar thing without having to customize script includes. You do your custom attribute or attributes as is and then you do a post-processing script and in it you can fetch the discovery schedule record, read attributes from it, and then apply those attributes to the CIs in your payload.

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @piotrkopytynski ,

 

Refer my content on post processing script, i have covered that too...: 

 

Set Discovery Schedule name to CMDB Record (via Discovery) 

piotrkopytynski
Tera Contributor

That's a script action, you can just a post processing script and access the payload directly.

Sohail Khilji
Kilo Patron
Kilo Patron

Can you elobrate more on how it can be attained with 1 post processing script for all discovery schedules ? It may help me or future readers !

Brian Dolinar
Tera Contributor

When using this method, it only sets the value on the directly Discovered CIs.

That is, even though the OOB action sets the location from the Schedule record on both directly Discovered CIs and other related CIs, the new field value only gets set on the direct CIs.

Trying to figure out what is setting the Location field and then copying that logic.


On this example, here is the list of the CIs being updated with both the location and company (I was using company instead of assignment group) and there are many more CIs which are only getting the OOB location update.

BrianDolinar_0-1751395484533.png

Discovery status device list

BrianDolinar_1-1751395619342.png

 



 

 

Version history
Last update:
‎04-24-2024 06:55 AM
Updated by:
Contributors