Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


--PeterC
2017-08-18T05:35:24Z
Hi,
Any thoughts on what's happening here?
I've got a job triggered by the Creation or Rename of a file.
The job contains one task -- run a Powershell script. For the purposes of testing I've winnowed it down to this:

Param ( [string] $inFile )
echo $infile
Get-Date -Format G >> \\VRUKAZCLEGTVR1X\Transfer\360T\Out.txt
echo $infile >> \\VRUKAZCLEGTVR1X\Transfer\360T\Out.tx

[xml]$TradeXML = Get-Content $inFile
$T = $TradeXML.trade

Start-Sleep -s 4


The parameter name is inFile, and it's value is {TRIGGER(Active|96f21a20-0584-41e7-a24e-618d6401e109|File.Result.FullPath)}

As you can see, the powershell script writes the path of each file that triggers the job to a file, Out.txt. When I copy (for example) four files:
Trade-7887250.xml
Trade-7887249.xml
Trade-7887234.xml
Trade-7887211.xml

to the input folder, the job gets triggered 4 times (good) but I get this from Out.txt:
8/18/2017 6:28:33 AM
\\VRUKAZCLEGTVR1X\Transfer\360T\Trade-7887234.xml
8/18/2017 6:28:34 AM
\\VRUKAZCLEGTVR1X\Transfer\360T\Trade-7887234.xml
8/18/2017 6:28:34 AM
\\VRUKAZCLEGTVR1X\Transfer\360T\Trade-7887234.xml
8/18/2017 6:28:36 AM
\\VRUKAZCLEGTVR1X\Transfer\360T\Trade-7887234.xml


I.e. I get the same filename 4 times. I've tried various changes to configuration, "Do not Start Job if already runnning", putting a wait at the end of the job, Using polling, etc. but I'm kind of out of options and I find it hard to believe that I can't get something so fundamental working.

I'd love any hints as to where I've gone wrong.

TIA

--Peter
Sponsor
Forum information
Guest
2017-08-18T15:33:11Z
Originally Posted by: --PeterC 

Hi,
Any thoughts on what's happening here?
I've got a job triggered by the Creation or Rename of a file.
The job contains one task -- run a Powershell script. For the purposes of testing I've winnowed it down to this:

Param ( [string] $inFile )
echo $infile
Get-Date -Format G >> \\VRUKAZCLEGTVR1X\Transfer\360T\Out.txt
echo $infile >> \\VRUKAZCLEGTVR1X\Transfer\360T\Out.tx

[xml]$TradeXML = Get-Content $inFile
$T = $TradeXML.trade

Start-Sleep -s 4


The parameter name is inFile, and it's value is {TRIGGER(Active|96f21a20-0584-41e7-a24e-618d6401e109|File.Result.FullPath)}

As you can see, the powershell script writes the path of each file that triggers the job to a file, Out.txt. When I copy (for example) four files:

Trade-7887250.xml
Trade-7887249.xml
Trade-7887234.xml
Trade-7887211.xml

to the input folder, the job gets triggered 4 times (good) but I get this from Out.txt:
8/18/2017 6:28:33 AM
\\VRUKAZCLEGTVR1X\Transfer\360T\Trade-7887234.xml
8/18/2017 6:28:34 AM
\\VRUKAZCLEGTVR1X\Transfer\360T\Trade-7887234.xml
8/18/2017 6:28:34 AM
\\VRUKAZCLEGTVR1X\Transfer\360T\Trade-7887234.xml
8/18/2017 6:28:36 AM
\\VRUKAZCLEGTVR1X\Transfer\360T\Trade-7887234.xml


I.e. I get the same filename 4 times. I've tried various changes to configuration, "Do not Start Job if already runnning", putting a wait at the end of the job, Using polling, etc. but I'm kind of out of options and I find it hard to believe that I can't get something so fundamental working.

I'd love any hints as to where I've gone wrong.

TIA

--Peter


Try adding a "Set Job Variable" task before your PowerShell task and set a job variable named "inFile" with the value "{TRIGGER(Active|96f21a20-0584-41e7-a24e-618d6401e109|File.Result.FullPath)}". Then set your PowerShell parameter equal to "{JOB(Active,Variable,inFile)}. See if that works.

You might have something that's only updating the base job and not the runtime instance. The runtime instance can only have its variables updated using a "Set Job Variable" task.
--PeterC
2017-08-20T14:31:18Z
Thanks Snap,

I tried using a Job Variable, but I'm still getting the same Full path multiple times.

Kind regards,

--Peter
--PeterC
2017-08-21T11:29:47Z
For those following at home the answer is...
Use {TRIGGER(Active|LastTrigger|File.Result.FullPath)}
Thanks Henrik!
Scroll to Top