- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2025 09:35 AM - edited ‎05-07-2025 09:42 AM
Hi,
I have written this after update br on change of a field and is working fine for existing records but I dont want it to run the very first time the record is creted. The record gets created through an ui action and so the field automatically gets field from the ui action but I want to stop this after update br to work for new records created but rather it should work only when a user manually changes the field.
(function executeRule(current, previous /*null when async*/ ) {
if (!current.isNewRecord()) {
var item = new GlideRecord('x_iem_tqa_work_request_items');
item.addQuery('associated_work_order_number.sys_id', current.sys_id);
item.addQuery('tag_report_anomaly_other', 'NOT IN', current.associated_work_request_item_number);
item.query();
while (item.next()) {
item.associated_work_order_number = '';
item.selected_work_items = false;
item.state = 'Planning Completed';
item.update();
}
}
})(current, previous);
Is there an alternative to do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2025 09:41 AM
if you want this BR to run only for manual changes then in BR condition add this check for empty
current.associated_work_request_item_number.changes() &&
!current.associated_work_request_item_number.nil()
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
‎05-07-2025 09:41 AM
if you want this BR to run only for manual changes then in BR condition add this check for empty
current.associated_work_request_item_number.changes() &&
!current.associated_work_request_item_number.nil()
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
‎05-07-2025 08:30 PM
Hope you are doing good.
Did my reply answer your question?
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