- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2023 09:58 AM
I created a Business Rule on the sc_request table that should change the child RITM's due date to the REQ's due date on update:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('sc_req_item');
gr.get('request.sys_id', current.sys_id);
gr.query();
gr.due_date = current.due_date;
gr.update();
})(current, previous);
When I debug Business Rules and update the REQ's due date, I see that this Business Rule is the only one running. If I update the REQ's due date and go to the child RITM, the due date is still the original due date, not the new one. However, if I look at the RITM's history, it shows the last update as the BR setting the due date to the new one:
Any idea why the RITM history shows the update occurring, but the due date value on the RITM form is not updating?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2023 12:30 PM
Please update the code.
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.sys_id);
gr.query();
while(gr.next()){
gr.due_date = current.due_date;
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2023 12:30 PM
Please update the code.
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.sys_id);
gr.query();
while(gr.next()){
gr.due_date = current.due_date;
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2023 12:49 PM
This worked... but I'm not sure I understand why. If I'm successfully grabbing the RITM object using gr.get(), why does iterating through the query actually update the value on the RITM, but using gr.get() and updating gr does not?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2023 12:51 PM
This worked... but I'm not sure I understand why. If I'm successfully grabbing the RITM object using gr.get() and seemingly updating the due_date, why does iterating through the query() actually update the value, but using gr.get() does not?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2023 03:00 PM - edited ‎11-14-2023 03:02 PM
In your case i believe you don't need 'request.sys_id', you can pass in 'request'. also by removing the query() line will work. for get method query is not required. Also typically it is used for single record, there is a good chance that there will be multiple records in this case so get is not recommended.