- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2020 11:17 PM
HI all,
I want to show Error message, if there are any open change tasks before closing change and form not going to submit(close) .
Here i wrote before business rule on change_request table
before update
when to run : state changes to closed
var activeTask = new GlideRecord('change_task');
activeTask.addQuery('active',true);
activeTask.addQuery('change_request', current.sys_id);
activeTask.query();
if (activeTask.next()) {
gs.addErrorMessage('This Change Request has currently opened tasks, and cannot be closed. Please close any open tasks before closing this Requested Item');
current.state = previous.state;
current.setAbortAction(true);
}
I followed 1 link..but it is not working for me..
I am able to close change before closing change tasks ..and it doesn't shows error message..
after closing the change, change tasks will get cancelled..
How to fix..
Thanks in advance..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2020 11:26 PM
Hi,
Try adding logs
update as below
var activeTask = new GlideRecord('change_task');
activeTask.addQuery('active',true);
activeTask.addQuery('change_request', current.sys_id);
activeTask.query();
if (activeTask.next()) {
gs.addInfoMessage('Inside if');
gs.addErrorMessage('This Change Request has currently opened tasks, and cannot be closed. Please close any open tasks before closing this Requested Item');
current.setAbortAction(true);
}
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
‎03-17-2021 05:29 AM
Hope you are doing good.
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
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
‎10-28-2020 01:06 AM
There is an OOB BR for your requirement, why do you need to create new BR?
Check open change_tasks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2020 01:24 AM
Hi,
But it is not working..i dont know why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2020 02:47 AM
Did you try adding logs
please share BR condition
It should be before Update
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
‎10-28-2020 01:15 AM
Hi Srujana,
Business rule seems to be fine. Can you check if there is some other Business rule that runs on before insert/update with an Order lower than the one that you use above.