- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 04:32 AM
Hi ,
I am writing an After Business rule on RITM table, where in as per requirement I also need to glide record to the same RITM table in that Business rule, Is it possible to call glide record of same table.
In the After Business rule, as current.update() should not be used, we were asked to use gr.update(); to satisfy the requirement.
Please guide me how to call the same table using glide record.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 07:29 AM
Hi,
If RITM has no approval then why to calculate the difference?
You should be concerned about only RITMs which have approval
After update BR on sysapproval_approver
Condition: current.source_table == 'sc_req_item'
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var ritm = new GlideRecord('sc_req_item');
ritm.get(current.sysapproval);
var opened = new GlideDateTime(ritm.sys_created_on);
var nowTime = new GlideDateTime();
var duration = GlideDateTime.subtract(opened, nowTime);
ritm.u_duration = duration;
ritm.update();
})(current, previous);
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
‎08-24-2022 07:48 AM
Hi Ankur,
Thanks for this, so this only calculates when we are having approvals. If there are no approvals, then the duration field will be blank.
I am having one more duration field where it calculates the total lifetime of the RITM (opened time till closed time)
These 2 fields will be on RITM table only, now here also I need to use after business rule and not to use current.update() .
I can achieve this with before update business rule, but as per our requirement , before should not be used.
So, here I need to write BR on RITM table and also glide record also to RITM Table? Please help me in high level approach how can I proceed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2022 02:47 AM
Hi,
2 scenarios
1) if RITM has approval then you can use logic I shared and if it doesn't have approval duration field will be blank. This is but obvious. -> BR on sysapproval
2) Other duration field you can anyhow populate by finding the difference of created and closure. -> Before Update BR on RITM
Now question is who informed you not to use before update BR on RITM and to use After BR only?
current.update() is not good practice.
You can query current record and update it using GlideRecord but why to do that?
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
‎08-27-2022 12:37 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
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
‎08-31-2022 01:10 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
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
‎09-19-2022 05:08 AM
This is as per the best practice document from ServiceNow documentation.
https://docs.servicenow.com/bundle/sandiego-it-service-management/page/product/planning-and-policy/concept/request-management-architecture.html