Update table business rule delete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2022 03:47 AM
I need to update a field in a table only when all the records in another table with a specific field type have been deleted. I am using a Business rule with the "Delete" on when to run.
my business rule script:
var user = current.u_userid;
var product = current.u_product; <----- need to check this field
var arr[];
var gr = new gliderecord('sys_user');
gr.addquery('sys_id', user);
gr.query();
if(gr.next()){
gr.setvalue('myfield', true);
gr.update();
}
Thanks
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2022 03:50 AM
First you are doing delete operation on some table. Once data is deleted then you are updating on user table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2022 03:59 AM
I am doing delete on a custom table, the field needs to be updated on the user table. In the custom table the field I need to check is u_product, if this has the value of "hardware" and only one records has been selected to be deleted then the flag in the user table is not updated. If all the records with "hardware" have been deleted from the custom table then the field is update in the user table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2022 03:51 AM
Hi,
So what debugging have you performed?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2022 04:00 AM
In the current state the field in the user table is updated but I need it only update when all the records with u_product are deleted.