Before BR with Update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 09:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 10:42 PM
Hi Ankur,
Its an Before Br to check and Update comments in Sctask from RItm. Business is asking Update in a Before BR is not best practice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 11:12 PM
BR is on RITM and you want to update another table SC Task.
Then ideally it should be after update BR.
We usually use before update BR if we want to set fields on the same table on which BR is defined
So please convert your BR to after update and you should be good to go
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 11:35 PM
HI @karthik65 ,
I trust you are doing great.
Please find the below reference code
function updateChildren(fieldName, msg) {
var rec = new GlideRecord("sc_task");
rec.addQuery('request_item', current.sys_id);
rec.orderBy();
rec.query();
var fieldRawValue = current.getValue(fieldName) + '';
var fieldValue = fieldRawValue.trim();
if (!fieldValue || fieldValue.length <= 0)
return;
while (rec.next()) {
if (fieldRawValue.indexOf('Comment copied from') == 0)
rec[fieldName] = fieldRawValue;
else
rec[fieldName] = msg + ': \n' + fieldRawValue;
if (rec.state == '-5' && (rec.request_item.request.requested_for == gs.getUserID() || rec.request_item.request.opened_by == gs.getUserID())) {
rec.setValue('state', '2');
}
// Comment out the next line to remove the update operation
// rec.update();
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi