using set abort action
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 01:10 AM
if user try to delete the any config item , if that particular item is associated with any other records like incident means , it should abort the delete action.
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 02:36 AM
Hi @keerthana ,
Hope you are doing great.
Navigate to "Business Rules" in ServiceNow and create a new one with the following details:
- Table: Configuration Item [cmdb_ci]
- When: Before
- Delete: checked
(function executeRule(current, previous /*, gs*/) {
var relatedIncidents = new GlideRecord("incident");
relatedIncidents.addQuery("cmdb_ci", current.sys_id);
relatedIncidents.query();
if (relatedIncidents.hasNext()) {
gs.addErrorMessage("This Configuration Item is associated with incident records and cannot be deleted.");
current.setAbortAction(true);
}
})(current, previous);
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma
Regards,
Riya Verma
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 07:30 AM
script ok, how to get a output because didn't open a configuration table