How to Display error message on Request Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 06:19 AM
Hi Team,
How to display an error message on the Request Item table, when a user closes the request item without completing the catalog task (Sc task).
I have tired the before update business rule with below code:
var gr = new GlideRecord("sc_task");
gr.addQuery("request_item", current.sys_id);
gr.query();
while (gr.next()) {
if (gr.active == true) {
gs.addErrorMessage("Please close all Sc Tasks and then close RITM");
current.state=8;
current.setAbortAction(true);
It's working fine, but the error message is displayed on both the requested item and catalog task also.
Regards,
Mahesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 04:31 AM - edited 08-08-2023 04:33 AM
Hey @maheshch18
What are your BR conditions? Below code is working fine for me.
BR table = sc_req_item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 04:45 AM
Hi Karishma,
It's working fine for me, But When I am trying the closing the catalog task displayed an error message like below:
Regards,
Mahesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 04:56 AM
Hi @maheshch18,
Since you want to prevent the Requested Item from Closing, it does not make sense to trigger the Business Rule on the sc_task table.
Create the BR on the sc_req_item table instead.
Condition: State [IS ONE OF] [Closed Complete/Closed Incomplete/Closed Skipped]
var gr = new GlideRecord("sc_task");
gr.addActiveQuery();
gr.addQuery("request_item", current.getUniqueValue());
gr.setLimit(1);
gr.query();
if(gr.hasNext()) {
gs.addErrorMessage("Please close all tasks before closing the Requested Item");
current.setAbortAction(true);
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.