How to prevent the state of a case from reverting to "New" after being set to "Open"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 09:50 PM
Hello Community,
When the request is created from the case in workspace/native UI, then the state of the case should not move back to New. How to prevent this.
Requirement : when state of existing request is moved to work in progress then state of case is moved from new to open ( functionality is already there). When one more request is created for the same case then state of case is moving back to new. Ideally it should be in the open only How to restrict it
There is already one BEFORE BR on sc_request for state sync.
Tried this way
if (current.state == 1 && b2bCase.state == 10) {
current.setAbortAction(true);
return;
}
but for the second time request is not getting created.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 09:59 PM
I suggest this
1) modify the logic so that case state is only set to "New" if it's not already in progressed state
2) script like this but please enhance
// Assume b2bCase is the GlideRecord for the associated case
if (b2bCase.state != 1) { // 1 = "New"
// Do NOT update the case state back to "New"
// Optionally, add logic to ensure state is set to "Open" or remains as is
} else {
// If the case is still "New", move it to "Open"
b2bCase.state = 10; // 10 = "Open"
b2bCase.update();
}
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-26-2025 10:46 PM
in the if block
I Tried to add the abort action, but is it restricting request.
So can you help me with the logic to retrict the state
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 10:56 PM
you can use current.setAbortAction(true) to stop the update
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-26-2025 11:17 PM
Yeah but current.setAbortAction(true) BR is on the sc_request Table
So it is restricting the request creation for the 2nd time
Thanks,