Hi All,
I am having trouble calling functions declared in Globals.ps1 from inside the JobScript{} block when using the Job Tracker framework for responsive forms. I understand the Job is running in a separate run space, and has no reference to functions declared in MainForm.psf or Globals.ps1. However, I thought it was possible to "dot source" the Globals.ps1 file inside the JobScript block which should work. When I try to dot source Globals.ps1 the file cannot be found. I then tried to use the sample function "Get-ScriptDirectory" to get the full path of the executing script. I saved this path to a variable and passed it into one of my jobs. I then used Set-Location to change the path of the new run space to the same location Get-ScriptDirectory returned. When I dot source globals.ps1, the file is found and everything works fine when running the project from inside Powershell Studio, but when I compile the project and run the .exe none of my global functions can be found, or execute at all.
I have multiple jobs that will call one or two of the same functions. I don't want to declare the same function multiple times across multiple JobScript{} blocks.
Any guidance or help pointing me in the right direction would be very appreciated.
Thank You
Responsive Forms - Call global function from inside JobScript{}
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Responsive Forms - Call global function from inside JobScript{}
You cannot call external functions from a job. Jobs run in a separate instance of PowerShell so they must contain all functions that are needed. Just include the functions in the job script.
Re: Responsive Forms - Call global function from inside JobScript{}
Agreed... Many head bangs on this one..