To close all tasks before closing requested item

moulik1
Kilo Guru

Hello All,

we have a scenario where user should not be able to close requested item until and unless all the tasks related to that requested item are closed,

for the same there is a before update business rule as below.

var rec = new GlideRecord('sc_task');

rec.addQuery('request_item',current.sys_id);

rec.addQuery('state','!=',3);

rec.query();

if(rec.next())

{

gs.addErrorMessage('Please close all the tasks before closing the requested item');

current.setAbortAction(true);

There is client script when status is closed all the fields will be made read only.

So the issue here is when user changes the status to close in requested item and updates it , it gives invalid update based on the above BR, and all the fields are greyed out because of the client script,

But actually the transaction is not complete (i.e. the requested item is still open), which user comes to know when he reloads or refresh the form which is actually mis-leading.

please let me know what are the modifications to be done.

Thanks

1 ACCEPTED SOLUTION

It seems like setAbortAction is not working . Following   thread may help you a little



setAbortAction not firing


View solution in original post

11 REPLIES 11

Strange but seems to be working,



have set current.stage = previous.stage instead of setabortaction.



Thanks.


salemsap
Tera Expert

Hi,


Just add one line at the end of BR like "gs.setRedirect(current);".


Try and lemme knw if u face any issue.




Thanks,


Alex