Reload the form after receiving error message " Invalid Update"

VijayKummamuru
Tera Expert

I am having a requirement problem should not be closed until all the problem tasks are closed. i am able to achieve the requirement with below business rule   , But the problem is form is showing the closed state until is manually reload it . I want form to reload automatically and set back to resolved state . 

 

Please help me on it 

 

 

VijayKummamuru_0-1742390547699.png

 

 

 

(function executeRule(current, previous /*null when async*/ ) {
    var Ptaskgr = new GlideRecord('problem_task');
    Ptaskgr.addQuery('state', '!=', 157);
    Ptaskgr.addQuery('problem', current.sys_id);
    Ptaskgr.query();
    if (Ptaskgr.next()) {
        gs.addInfoMessage('Please close the related Problem tasks first.');
        current.setAbortAction(true);
    }
})(current, previous);
 
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@VijayKummamuru 

if it's aborted then you cannot reload it

try this

(function executeRule(current, previous /*null when async*/ ) {
var Ptaskgr = new GlideRecord('problem_task');
Ptaskgr.addQuery('state', '!=', 157);
Ptaskgr.addQuery('problem', current.sys_id);
Ptaskgr.query();
if (Ptaskgr.next()) {
gs.addInfoMessage('Please close the related Problem tasks first.');

current.state = previous.state;
current.setAbortAction(true);
}
})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@VijayKummamuru 

Would you mind closing your earlier questions by marking appropriate response as correct?

Members have invested their time and efforts in helping you.

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@VijayKummamuru 

if it's aborted then you cannot reload it

try this

(function executeRule(current, previous /*null when async*/ ) {
var Ptaskgr = new GlideRecord('problem_task');
Ptaskgr.addQuery('state', '!=', 157);
Ptaskgr.addQuery('problem', current.sys_id);
Ptaskgr.query();
if (Ptaskgr.next()) {
gs.addInfoMessage('Please close the related Problem tasks first.');

current.state = previous.state;
current.setAbortAction(true);
}
})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

terrillc
Tera Contributor

is it sloved now?