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

So what customization makes the state go to Closed? Why not have a look at that?

Just applying setWorkflow(false) for this feels like a quick escape / easy workaround. Will work, though have a look at the actual issue instead of working around it.

So in my opinion, not a valid use of setWorkflow(false).

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

then what should be the approach

Like I mentioned:

So what customization makes the state go to Closed? Why not have a look at that?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

I have wrote a code in my run activity script:

current.close_notes = "rejected ";
current.close_code = "unsuccessful";
current.state = 3;

 

can you please help me to achieve this through script include

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.