- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 04-24-2024 06:55 AM
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.
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 ?
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)
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).
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)
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...
<<< Top Articles >>>
- ServiceNow Integration with Splunk
- LDAP Integration with ServiceNow
- ServiceNow Integration with Veeam
- Handling ServiceNow flow errors with a flow
- Show parent child incident relationships - display in field message
- ServiceNow SSO Logout Error (redirects to logout page) – Reason, Fixes and Cause.
- Multi Row Variable set ServiceNow MRVS - Creating - Scripting - Example - Limits
- ServiceNow Integration with MAC vendor - Get Mac vendor for the given MAC Address.
- How to find Log4j vulnerable severs in ServiceNow Using CMDB Query Builder (SecOps)
- How to Cancel a Long-Running Transaction ServiceNow
- Hidden Features for System Administrators
- Servicenow RPA - Understanding Attended / Unattended / Skilled Automation Bots
- Servicenow vCenter Discovery | Step by step Discovering VMware using vCenter Discovery.
- Set Discovery Schedule name to CMDB Record (via Discovery)
- Step by Step - How to discover Linux Servers in ServiceNow
- How to Generate PDF from UI action.
- Servicenow Discovery Implementaion Requirement Gathering & Pre-requisites.
MF Sohail Khilji | Servicenow Developer / Consultant.
Connect On LinkedIn > https://www.linkedin.com/in/mf-sohail-khilji/
#Discovery #ITOM #Servicenow
- 1,578 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
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.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
That's a script action, you can just a post processing script and access the payload directly.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
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 !

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
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.
Discovery status device list