42
Import-Module "$env:POWERJOBS_MODULESDIR\coolOrange.PowerJobs.VaultHelper.psm1"
$file = PrepareEnvironmentForFile "Assembly1.iam" $true
$powerJobs.Log.Info("Starting job 'change_state_child' ...")
#All LifeCycleDefinitions get hooked, you need them to set a filestate
$def = $vault.DocumentServiceExtensions.GetAllLifeCycleDefinitions()
#In this case we take the "Flexible Release Process"
$FlexibleReleaseProcess = $def | Where-Object {$_.DispName.Equals("Flexible Release
Process")}
#From the "FlexibleReleaseProcess"-object you can take your favorite state to set
$releaseState = $FlexibleReleaseProcess.StateArray | Where-Object
{$_.Name.Equals("Released")}
#Get all childfiles
$assocs = $vault.DocumentService.GetFileAssociationsByIds(@($file.EntityIterationId),
[Autodesk.Connectivity.WebServices.FileAssociationTypeEnum]::None,$false,
[Autodesk.Connectivity.WebServices.FileAssociationTypeEnum]::All,$true,$false,$false)
if($assocs[0].FileAssocs -ne $null){
$stateIds = @()
$childfileIds = @()
foreach($f in $assocs[0].FileAssocs){
$childfileIds += $f.CldFile.MasterId
$stateIds += $releaseState.Id
}
}
#The childfilesstates get changed to "Released"
$vault.DocumentServiceExtensions.UpdateFileLifeCycleStates($childfileIds,$stateIds,"Re
leased from PS")
Changing categories
Import-Module "$env:POWERJOBS_MODULESDIR\coolOrange.PowerJobs.VaultHelper.psm1"
$file = PrepareEnvironmentForFile "Part2.ipt.pdf" $true
$powerJobs.Log.Info("Starting job 'change_category' ...")
#All category-definitions get hooked
$defc = $vault.CategoryService.GetCategoriesByEntityClassId("FILE",$true)
#In this case we want to set the filecategory to "Engineering"
$category = $defc | Where-Object {$_.Name.Equals("Engineering")}
#Change Category
$vault.DocumentServiceExtensions.UpdateFileCategories(@($file.EntityMasterId),$categor
y.Id,"Category Change by PS")
Create a textfile via template
To use the script, create a file "C:\template.txt". Write your desired text and the variables for the properties in the file.
The syntax is as following:
The format is flexible. You could also define a html page.
Text text text text {Propertiename};