After a job completed, another job has to be placed in the Job Queue for the exact same file and with additional arguments
At the end of the job, a new job can be placed in the Job Queue using the Add-VaultJob cmdlet.
If the new job has to be executed for a specific entity, some -Parameters have always to be passed, these include the ID of the entity and it's EntityClass.
In order to pass additional parameters e.g. to update a property on the actual file with some value detected in the current job, you can add them to the -Parameters argument using following code:
Write-Host "Starting job 'Create PDF as attachment' for file '$($file._Name)' ..."
$vaultPDFfileLocation = ...
...
# END OF JOB
Add-VaultJob -Name "UpdateFileProperties" -Description "Update File Properties" -Priority 100 -Parameters @{
"EntityId" = $file.Id;
"EntityClassId" = $file._EntityTypeID;
"PDFVaultLocation" = $vaultPDFfileLocation
}
Write-Host "Completed job 'Create PDF as attachment'"
The $file object is automatically available for us in the newly added job now.
Also the custom argument "PDFVaultLocation" can be directly accessed via the $job object using $job.PDFVaultLocation:
Write-Host "Starting job 'UpdateFileProperties' for file '$($file._Name)' ..."
Update-VaultFile $file._FullPath -Properties @{ 'PDF Location' = $job.PDFVaultLocation }
...
Remarks