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

venkatiyer1
Giga Guru

Hi Neema,



Under Scheduled workflows, go to business rules for that table and you should be able to spot "Set Workflow scheduler script ", if you go to the script of that business rule you should be able to edit the above line var ws = new WorkflowScheduler(); ws.run(); as it is running from there.


Hi Venkat,



Thanks for the prompt response.



In an effort to not change anything globally specced within my scoped app (which I believe will fail certification if I do so), I attempted to clone this Business Rule and add the Condition where if the Application is my scoped app, it will run my Business Rule.



I edited the line to be:



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



However, when executing the Workflow Schedule, it still provides the original error:



java.lang.SecurityException: WorkflowScheduler undefined, maybe missing global qualifier


Caused by error in <refname> at line 1



==> 1: var ws = new WorkflowScheduler(); ws.run();



Additionally, I went ahead and changed the global Business Rule "Set workflow scheduler script" to include the global identifier, and still get the same error, as if the change I made never took effect.


venkatiyer1
Giga Guru

Hi Neema,



Yes, you need to use global.WorkflowScheduler() and I just checked the WorkflowScheduler (script include). But the issue here is this scheduler is not defined in your custom application. It is still defined in global application and the condition to check the application name would not help here. So you need to define the scheduler in your custom application and call the script include from there using global namespace.


Hi Venkat,



I am not quite sure I understand fully... This is my setup:



I have a Workflow Schedule created within my scoped application:


Untitled.png



I have a Business Rule also created within my scoped application that should call the "WorkflowScheduler" script include using the global namespace.



Do I also have to clone the "WorkflowScheduler" script include within my scoped app? What steps am I missing? To me it seems like my scheduler is defined in the custom application and should be using the Business Rule that has the condition which says "Application == My Scoped App".



Thanks,


Neema