How to create a PDF file from Drawings associated to an Item on Item Lifecycle Transition

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

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 Processor 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