How best to perform check for open change tasks and prevent move to Change State Review if there are any?

jas101
Tera Expert

Hi guys, when our users click 'Review' on the change request form what is the best way to check for any open change tasks at that time and if there are any, prevent the State from changing to 'Review' i.e. just cancel the UI action's 'actions'?

Many thanks.

 

5 REPLIES 5

Ahmmed Ali
Mega Sage

Have a before update business rule on change_request table. give condition as state changes to review.

in script query change task for this change and if any active tasks present, then use current.setAbortAction(true); to prevent the change update.

 

Thanks,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Hi, thanks for the reply. Should the script you refer to go in the business rule? Any help with the script would be most appreciated.

below is BR definition.

find_real_file.png

find_real_file.png

 

script:

 

(function executeRule(current, previous /*null when async*/) {

// Add your code here

var gr = new GlideRecord("change_task");
gr.addActiveQuery();
gr.addQuery("change_request",current.sys_id);
gr.query();
if(gr.next()){
current.setAbortAction(true);
}

})(current, previous);

 

Thanks,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

This is great, many thanks Ali. 

Can the same principle be applied for this other, slightly more complex scenario:

-When change request state moves to 'Assess' (i.e. when 'Request approval' is clicked)

-Check that change tasks fields have been completed e.g. fields below are not NULL

--Assignment group

--Planned start

--Planned end

Bonus question! Can you also check that 'Description' field in CTASK is not 'Describe the work' i.e. that the template text that auto appears on the CTASK when it has been created by the workflow has been modified by a user?

Many thanks!