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

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Completetly up to your situation/need. It can be valid to use setWorkflow(false) sometimes. For example, if you are updating records and don't want Business rules or Workflows to be triggered.

It would be different if you would always use this. That would be odd 🙂 Though it really depends on your situation if it's useable or not.

For the usage, see:
https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=r_GlideRecord-setWorkFlow_Boolean

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

hi mark,

 

Am using this in my change request workflow where i set the value false so is it right way to proceed 

The question: what is the need for your query? Just for every GlideRecord query... absolutely not! If it's for a valid reason, like on purpose you don't want Business rules to execute, oke fine.

So again, why do you want to use setWorkflow(false)? What is your need? Or is it just because someone told you about this option and your thinking that could be nice? Though actually there's no reason for applying it?

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 customized change request  workflow where after approver's rejection it goes new state ideally but customization it goes to closed state.

however, i used current.setworkflow(false) in my wf

so is this the correct way