The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Update 'Discovery Schedule Name' when the CI is update by Discovery.

Sohail Khilji
Kilo Patron
Kilo Patron

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....

LinkedIn - Lets Connect

1 ACCEPTED SOLUTION

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();
    }
}());

 

View solution in original post

6 REPLIES 6

shloke04
Kilo Patron

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

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0864114#:~:text=When%20using%....

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

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....

LinkedIn - Lets Connect

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.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

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();
    }
}());