current.setWorkflow(false);

Servicenow10
Kilo Guru

can anyone explain me why using current.setWorkflow(false) should not be followed or is it an unethical way?

and if i use would it be a  wrong method for a developer 

curious to know just for knowledge

 

thanks 

 

1 ACCEPTED SOLUTION

Hi,

In this current case, where the requirement is to have CR state to be closed (instead of cancelled) When it is rejected.

The OOB BR restricts the change of state.

Hence suggested to use setworkflow(false) in the run script so that the Br does not run on this record and the state is changed to closed.

Kindly mark the comment as a correct answer and helpful if it helps.

View solution in original post

12 REPLIES 12

sivaprince231
Giga Expert

Prior to updating your task, add a call to setWorkflow(false) on the GlideRecord object for the task within the business rule that is updating the task. This prevents the business rules from being processed.

 

 

hi

 

according to you which br should be stop if i stop this State model - Can change state? this will affect others too which i don't want

Hi,

In this current case, where the requirement is to have CR state to be closed (instead of cancelled) When it is rejected.

The OOB BR restricts the change of state.

Hence suggested to use setworkflow(false) in the run script so that the Br does not run on this record and the state is changed to closed.

Kindly mark the comment as a correct answer and helpful if it helps.