Custom delete button

Kumar38
Kilo Sage

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

Voona Rohila
Kilo Patron
Kilo Patron

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

I think , I made mistakes are when copying this to post. Tried without typo , still issue exists