Custom delete button
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 11:33 PM - edited 06-09-2023 12:56 AM
I'm working on a Scoped Application and created a delete buttonto delete current record and its related tasks.
Script isn't deleting record. Client is checked to false and its a form button.
var currentRecord = current.sys_id;
gs.info('currentRecord---'+currentRecord);
var grTasks = new GlideRecord('CustomTableExtendingTask');
grTasks.addQuery('parent', currentRecord);
grTasks.query();
while(grTasks.next())
{
gs.info('Related task found---');
grTasks.deleteRecord();
}
current.deleteRecord();
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 12:41 AM
hi @Kumar38
There was a typo mistake in line 4
Try this :
var currentRecord = current.sys_id.toString();
gs.info('currentRecord---'+currentRecord);
var grTasks = new GlideRecord('CustomTableExtendingTask');
grTasks.addQuery('parent', currentRecord);
grTasks.query();
while(grTasks.next())
{
gs.info('Related task found---');
grTasks.deleteRecord();
}
current.deleteRecord();
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 12:45 AM
I think , I made mistakes are when copying this to post. Tried without typo , still issue exists