$customObject variable is missing in Job

Issue

When adding a job via the powerJobs Processor settings dialog the $customObject is missing in the job

Cause

This happens because the powerJobs Processor settings dialog sets the EntityClassId of the job to a global unique id instead of "CUSTENT"

Solution

As a workaround add the following lines at the top of your costom entity job script

if (-not $customObject) {
   $custEnt = $vault.CustomEntityService.GetCustomEntitiesByIds($job.EntityId)[0]
   $global:customObject = New-Object Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.CustomObject($vaultConnection, $custEnt)
}