The CreatorCon Call for Content is officially open! Get started here.

How to Display error message on Request Item

maheshch18
Tera Contributor

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

7 REPLIES 7

Hey @maheshch18 

What are your BR conditions? Below code is working fine for me.

BR table = sc_req_item

KarishmaDubey_0-1691494367721.png

KarishmaDubey_1-1691494399104.png

 

 

Hi Karishma,

 

It's working fine for me, But When I am trying the closing the catalog task displayed an error message like below:

 

maheshch18_0-1691495119036.png

Regards,

Mahesh

Peter Bodelier
Giga Sage

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.