setWorkflow(false) not working in scoped HR app

Swapnil Shirsik
Giga Guru

Here is a thing.. There is a business rule in scoped app that adds a comment when a record is updated. We need to stop this BR while we are running a scheduled script.

Commonly, we use setWorkflow(false) but it is not working. I tried to create a global script include and then call this script through schedule, still no luck.

 

Did anyone faced similar issue?

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Swapnil Shirsik 

are you using setWorkflow(false) on global or some other scope?

if your business rule is created in same scope i.e. custom one then it should be allowed

if your BR is in another scope then it won't work

setWorkflow() cross-scope access issue

setWorkflow api cannot be used for cross scoped applications.

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

Ian Mildon
Tera Guru

Do not use a global script include for scoped HR work. Much better to insure you create it under the correct scope and that the first two lines of the script include are similar to this to extend the global functions into the scope

var FetchUserDetails = Class.create();
FetchUserDetails.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {