I wanted to delete related records in other table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2016 06:57 AM
Hi All,
I have two tables. 1) For Services which is nothing but a list of services. 2) Appointmnets for services.
When I delete any service from first table I like to delete related records from the other tables. Any suggestion
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2016 07:06 AM
write a delete after business rule on the first table with a script like below:
var gr = new GlideRecord('2nd table name');
gr.addQuery('field name that contains the service', current.sys_id); //assuming the field is a reference
gr.query();
gr.next();
gr.deleteMultiple();
Replace the table and field names properly. Let me know the result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2016 11:23 PM
Hi,
Do you need any other assistance on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2016 01:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2016 01:19 AM
So the new requirement is if admin try to delete a record from service table, it will check that if any appointment is there in appointment table with that service. If yes, system will show alert. Is my understanding correct?
Now when you say alert, that means after clicking on Ok it will delete the service record. Right? Or you you want not to delete that?