WorkflowScheduler undefined, maybe missing global qualifier

nshabestari
Kilo Contributor

Has anyone seen this issue when scheduling a workflow within a scoped application?:

WorkflowScheduler undefined, maybe missing global qualifier

My workflows and activities are all created on a scoped app. Is it possible to create a Workflow Schedule and alter the back-end call? In log I see the line failing is:

var ws = new WorkflowScheduler(); ws.run();

I do not see a way to change this call from the Workflow Schedule table, however. Pretty certain the solution would be to make the call "new global.WorkflowScheduler();", however I do not see a place to change this script from the Workflow Schedules table.

The end goal is to schedule the workflows that are in the scoped app to run every X minutes.

Regards,

Neema

1 ACCEPTED SOLUTION

Hi Neema,




Can you please try with below script



if (current.sys_scope.getDisplayValue() == 'Global') current.script = "var ws = new WorkflowScheduler();



ws.run();";



else current.script = "var ws = new global.WorkflowScheduler();



ws.run();";




Please put few log statements and check which line is getting executed.


View solution in original post

12 REPLIES 12

Hi Neema,



I see that you have defined the custom application in the application field. This is what i was mentioning actually. Thanks for sharing the screenshot. One thing do check is on the script include see if the accessible from is selected to be all application scopes. If that is the case and you are still getting the issue, one option would be to raise the HI ticket to see why it is not accessible. Other would be to copy this script include into your custom application and call directly instead of global.WorkflowScheduler.



save image


The script include appears to show that it is accessible from "All Application Scopes".



I will open a HI ticket to see why it is not accessible and attempt the other workaround as well.



Thanks,


Neema


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Neema,



This is a known issue and the PRB number is PRB657531



Current Workaround


There is business rule called as 'Set workflow scheduler script'.   Below script used as a workaround


current.script = "var ws = new global.WorkflowScheduler(); ws.run();";


Hi Pradeep,



I have altered the Business Rule called 'Set workflow scheduler script' to use the workaround and added the global qualifier. Upon saving I re-created my Workflow Schedule and executed, but the error is the same as before. Am I still missing any steps or is this a bug in the platform? See screenshot below:





Thanks,


Neema


Hi Neema,




Can you please try with below script



if (current.sys_scope.getDisplayValue() == 'Global') current.script = "var ws = new WorkflowScheduler();



ws.run();";



else current.script = "var ws = new global.WorkflowScheduler();



ws.run();";




Please put few log statements and check which line is getting executed.