how to close Ritm when all SCTask close And get error message user to try close Ritm when any one Sctask is in open state.?

suresh40
Tera Contributor

Hi All,

I have written business rule on ritm and sc task table 

1) if user try to close ritm , it shouldn't close and get error message and revert back to pervious state. Its working fine 

Businees rule:

Table Sc_req_item

 Before Update BR condition is this

State [IS ONE OF] [Closed Complete, Closed Incomplete, Closed Skipped]

order 1000

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.setAbortAction(true);
}
}

 

2) When all sc task close ritm has to close automatically its also working fine .

Business Rule :

Table sc_task

 After Update BR condition is  Active changes to false 

Order 1000

var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.request_item);
gr.addQuery('active', true);
gr.query();
if (!gr.next()) {
var ritm = current.request_item.getRefRecord();
ritm.state = 3;
ritm.update();
}

 

Now my issue is user raising the ticket ,for one RITM multiple sctask is there , If user try close the sctask its redirecting to ritm and its showing Error message . My requirement is user try close the SCTASK ticket don't show error message . if user try close Ritm, if any one sc task is open state then error message has to visible . Please help me on this.

 

Thanks,

Suresh

14 REPLIES 14

ersureshbe
Giga Sage
Giga Sage

 Hi, 

This Business rule should write part of sc_req_item table

gs.addErrorMessage("Please close all Sc Tasks and then close RITM");
current.setAbortAction(true)

When all task should close then RITM should close scenario- you should write the Business Rule in sc_task table.

R,

Suresh.

Regards,
Suresh.

Hi Suresh,

I have written Business rule in sc_req_item table only for error message and for Ritm auto close i have written in sc_task table only both are working fine.

 

But my issue is In one ritm multiple sctask is there , If user try close sc tack and its redirecting to ritm and showing error message , Error message has to show only when user try to close ritm manullay if any one sc task is open state .

 

Thanks, 

Suresh

Hi,

Can you add one filter condition in sc_req_item table business rule

ie., updated by is not system.

R,

Suresh.

Regards,
Suresh.

Hi Suresh,

 

Its not working .