GlideDateTime() works on one flow, 'Error: "GlideDateTime" is not defined' on the other

Josh102
Kilo Guru

Hello

Flow 1 uses the following inline script to generate a value for a 'description' input to a custom action:

 

var time = new GlideDateTime();
var desc = "Terminated via ServiceNow Orchestration " + time.getDisplayValue();
return desc

 

This works successfully and passes the value with the current date and time displayed

 

Flow 2 uses the exact same inline script (copy-pasted) to generate a value for the same input for the same custom action. Flow 2 errors on that custom action with the following error message:

IPaaSActionProbe | Operation(Flow 2.b8f274781bd87550d11720a7b04bcb9f.InlineScript_description5ef2f4784dd8755071c128e5866d4864) failed with error: com.snc.process_flow.exception.OpException: Error: "GlideDateTime" is not defined.
at com.snc.process_flow.operation.script.ScriptOperationBase.handleScriptResult(ScriptOperationBase.java:64)
at com.snc.process_flow.operation.script.ScriptOperationBase.runScript(ScriptOperationBase.java:52)
at com.snc.process_flow.operation.script.ScriptOperation.run(ScriptOperation.java:74)
at com.snc.process_flow.engine.Operation.execute(Operation.java:212)
at com.snc.process_flow.restricted_caller_access.ExecuteWithoutCallerAccessTracking.executeWithMetaStack(ExecuteWithoutCallerAccessTracking.java:10)
at com.snc.process_flow.engine.ProcessEngine.executeOps(ProcessEngine.java:597)
at com.snc.process_flow.engine.ProcessEngine.runInternal(ProcessEngine.java:498)
at com.snc.process_flow.engine.ProcessEngine.resume(ProcessEngine.java:489)
at com.snc.process_flow.engine.ProcessAutomation.run(ProcessAutomation.java:84)
at com.snc.process_flow.engine.ProcessAutomation.run(ProcessAutomation.java:60)
at com.snc.process_flow.engine.ProcessAutomation.resume(ProcessAutomation.java:56)
at com.snc.process_flow.engine.MidProcessAutomation.resumeFlow(MidProcessAutomation.java:55)
at com.service_now.mid.probe.IPaaSActionProbe.lambda$probe$0(IPaaSActionProbe.java:126)
at com.glide.util.LogContext$Frame.run(LogContext.java:247)
at com.service_now.mid.probe.IPaaSActionProbe.probe(IPaaSActionProbe.java:96)
at com.service_now.mid.probe.AProbe.process(AProbe.java:154)
at com.service_now.mid.queue_worker.AWorker.runWorker(AWorker.java:131)
at com.service_now.mid.queue_worker.AWorkerThread.run(AWorkerThread.java:20)
at com.service_now.mid.threadpool.ResourceUserQueue$RunnableProxy.run(ResourceUserQueue.java:649)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)

 

The expected behaviour is that Flow 2 would behave the same way as Flow 1. Could someone help me to identify why this is happening?

 

I have a feeling this has something to do with Scope, and I'm not very familiar with scopes, I usually do everything in Global. Both flows are published, and in the Global application. The custom action is published and in the Global application.

The only difference between the flows that I can see when I go to sys_hub_flow.list; The Compiler Build for Flow 1 is empty, but the Compiler Build for Flow 2 is "glide-utah-12-21-2022__patch4-hotfix2-06-23-2023_06-23-2023_2224.zip". 

It may also be worth noting that Flow 1 was a test flow created to test this error and it only has the single action. Flow 2 is a larger flow with 13 actions leading to it. 

 

Flow 1 was originally set with a 'Run Once' trigger and Flow 2 has always used 'Service Catalog' trigger. I've updated Flow 1 to also use the 'Service Catalog' trigger in order to troubleshoot this issue, but it has not changed the behavior. 

1 ACCEPTED SOLUTION

strbrindha
Giga Expert

Work Around: Instead of writing the Javascript in flow designer update record java script (inline script), We've created one action which contains java script step where due date was updated using the same new GlideDateTime() which works as expected. Its the bug in the flow designer

View solution in original post

6 REPLIES 6

Daniel Peel
Mega Sage

@kalair Yes, basically the provided work around from ServiceNow was to use a Script step in front of my step.  The issue, it seems... is that when I used my Rest Step, makes a call via a MID server... the internal scope changes to the MID server's scope.  The script include in my scoped application, isn't callable from the scope the MID server is in.  I have not tried to add any cross scope for that... as I thought it was global and there is cross scope for that... so either way... they aren't fixing anything and yes it's broken... as usual lol.  So try to add a script step in your action that does what you inline script is doing and then use the output for that field the incline script was using.  

@Daniel Peel Thanks for the quick response. Yes, I already applied the given workaround. Thank you 🙂