Question on SCCM
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 03:15 AM
Hi All,
I have one Question on Assets.
In SCCM assets are not present, but they are present in ServiceNow, and I don't want those assets in ServiceNow Aswell.
Some Assets in SCCM are retired but those are still present in ServiceNow, so i need to delete those Assets in ServiceNow Automatically not Manually.
So can anyone please help me how can i achieve this.
Thanks,
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 03:22 AM
Hi @Mani60
can you please try to using following code -
To automatically delete assets in ServiceNow that are not present in SCCM, you can use a business rule. The business rule should check if the asset exists in SCCM and if it does not, the business rule should delete the asset from ServiceNow.
Here is an example of a business rule that you can use:
function executeRule(current, previous) {
// Get the asset's SCCM ID.
var sccmId = current.getValue('sccm_id');
// Check if the asset exists in SCCM.
var sccmAsset = new GlideRecord('sc_cmdb_ci_sccm_system');
sccmAsset.addQuery('sys_id', sccmId);
sccmAsset.query();
// If the asset does not exist in SCCM, delete it from ServiceNow.
if (!sccmAsset.next()) {
current.deleteRecord();
}
}
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar