- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2024 10:55 PM
We have multiple discovery schedule running on scheduled basis, I want to update the Name of the discovery schedule in ''CI description'' field when ever discovery updates the CI during discovery.
Example :
Discovery Schedule Name : Berlin_datacenter_Vcenters.
CI Description Field Value to be updated as : Updated by 'DISCOVERY > Berlin_datacenter_Vcenters'.
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 01:52 PM
This one peaked my curiosity. Neat idea.
(function() {
var comment = "Updated by schedule:" + current.status.dscheduler.name + '';
var updated_ci = new GlideRecord("cmdb_ci");
if (updated_ci.get(current.cmdb_ci.sys_id)) {
updated_ci.setValue('comments', comment);
updated_ci.update();
}
}());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 01:22 AM
HI @Sohail Khilji ,
OOTB ServiceNow does the same behavior for Location attribute and is passed from Discovery schedule to a CI record.
You can follow the same process to do so for other fields.
When a discovery for a device completes, a discovery.device.complete event is triggered. Script Actions process such events and take action. Therefore, another option would be to create a script action, "System Policy > Events > Script Actions", which would update such field accordingly when processing the discovery.device.complete.
In the following example, the script action dot walks to the schedule and collects the sys_updated_on field and logs it:
(function() {
var updateOn = current.status.dscheduler.sys_updated_on + "";
gs.log("updateOn: " + updateOn, "updateOn");
}());
The same has been explained in below 2 HI articles for more reference:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0820001
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 01:31 AM - edited 01-09-2024 06:49 AM
I did read them but they were not helpfull in updating the description field as per my requirement.
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 01:53 AM
Hi @Sohail Khilji ,
Location one does work and gets populated. I think so what has been documented in HI article should work.
Do try and let me know.
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 01:52 PM
This one peaked my curiosity. Neat idea.
(function() {
var comment = "Updated by schedule:" + current.status.dscheduler.name + '';
var updated_ci = new GlideRecord("cmdb_ci");
if (updated_ci.get(current.cmdb_ci.sys_id)) {
updated_ci.setValue('comments', comment);
updated_ci.update();
}
}());