Issue

When an item changes lifecycle transition, a PDF of all associated drawings has to be created.


Solution

This sample code can be added to a specific item lifecycle transition. The code will get all drawings associated to the item and queue the sample PDF job delivered with powerJobs for each drawing. You can also queue your own job by changing the -Name parameter in the Add-VaultJob cmdlet.

if ($item) {
    $itemAssocs = Get-VaultItemAssociations -Number $item.Number
    $drawings = $itemAssocs | Where-Object { $_._Extension -eq 'dwg' -or $_._Extension -eq 'idw'}
    if ($drawings -ne $null) {
        foreach ($drawing in $drawings) {
            $addedJob = Add-VaultJob -Name "Sample.CreatePDF" -Description "Create PDF from drawings associated to item number '$($item.Number)'" -Parameters @{
                "EntityId" = $drawing.Id
                "EntityClassId" = $drawing.'Entity Type ID'
            }
        }
    }
    else {
        Write-Host "No drawing found for item '$($item.ItemNum)'"
        return 
    }
}
else {
    Write-Host "The job was not executed for an item"
    return
}


Remarks

Add a job on lifecycle transition (coolOrange knowledge base)

Get-VaultItemAssociations (coolOrange wiki)

Add-VaultJob (coolOrange wiki)