Powershell to get Vault Change Order ID #?

ThomasRambach
Advisor

Powershell to get Vault Change Order ID #?

ThomasRambach
Advisor
Advisor

I need to get the vault change order id number for input on a few change orders that we imported into Fusion Lifecycle before our integration tool was ready. Does anyone have a quick and easy powershell script to get the change order ids?

 

 

0 Likes
Reply
Accepted solutions (1)
1,348 Views
11 Replies
Replies (11)

sajith_subramanian
Autodesk Support
Autodesk Support
Accepted solution

Hi @ThomasRambach,

 

If I understand your requirement correctly, you want to fetch the Change order Id's for your given Change order numbers?

I am not an expert on powershell, but take a look at the below script that does something similar

Add-Type -Path ("C:\Program Files (x86)\Autodesk\Autodesk Vault 2018 SDK\bin\x64\Autodesk.Connectivity.WebServices.dll")
$serverID = New-Object Autodesk.Connectivity.WebServices.ServerIdentities
$serverID.DataServer = "myServerName"
$serverID.FileServer = "myServerName"
$VaultName = "MyVault"
$UserName = "Administrator"
$password = ""
$cred = New-Object Autodesk.Connectivity.WebServicesTools.UserPasswordCredentials($serverID, $VaultName, $UserName, $password)
$vault = New-Object Autodesk.Connectivity.WebServicesTools.WebServiceManager($cred)
$co = $vault.ChangeOrderService.GetChangeOrderByNumber("ECO-000020") # input eco number here
$co.Id  #required id number


$vault.Dispose() 

Hope this helps.

 

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network

ThomasRambach
Advisor
Advisor

That worked absolutely perfectly. Thank you.

0 Likes

J_Dumont
Advocate
Advocate

I'm using powershell and i wonder if it would it be possible to get the change order number of a file of its controlled by a change order?

 

0 Likes

Markus.Koechl
Autodesk
Autodesk

You can get it using ChangeOrderService.GetChangeOrderFilesByFileMasterId. The extended sample configuration VDS-PDMC-Sample implemented it as part of the Revision tab:

	#copy number if ECO drives the revision
	$mFile = mGetVaultFile
	$mEcoFile = $vault.ChangeOrderService.GetChangeOrderFilesByFileMasterId($mFile.MasterId)
	if ($null -ne $mEcoFile) {
		$mEcoNum = $mEcoFile[0].ChangeOrder.Num
		$Prop["Change Descr"].Value = $mEcoNum
	}


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe

J_Dumont
Advocate
Advocate

Hi Markus,

 

That worked perfectly!! Thank you.

If I could impose just a bit more.

 

Now that I have the ECO Number, I would like to update a Property with it.

I've tried using the UpdateFileProperties but I'm having issues with the syntax.

 

 

0 Likes

Markus.Koechl
Autodesk
Autodesk

Likely, you struggle to build the dictionary. There are solved samples around: Solved: Re: UpdateFileProperties Error in 2017 - Autodesk Community - Vault

Or my GitHub samples: iLogic-Vault/iLogic-Vault-QuickstartLibrary/iLogic-Vault QuickstartLibrary.cs at 2023.3 · koechlm/iL...



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes

J_Dumont
Advocate
Advocate

Thanks for the info but I see the information is in C+ and I'm not sure how to code this in Powershell.

 

This is what I have so far but I'm getting an error in the last line as shown below.

Exception calling "UpdateFileProperties" with "2" argument(s): "1136"

 

$FileMID=$file.MasterID
$mEcoFile = $vault.ChangeOrderService.GetChangeOrderFilesByFileMasterId($FileMID)
$mEcoNum = $mEcoFile[0].ChangeOrder.Num


$unmappedPropertyName = "Cost"

$propDefs = $vault.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
$myProperty = $propDefs | Where-Object {$_.DispName -eq $unmappedPropertyName }
$propInstParamArray = New-Object Autodesk.Connectivity.WebServices.PropInstParamArray
$propInstParamArray.Items += New-Object Autodesk.Connectivity.WebServices.PropInstParam -Property @{PropDefId = $myProperty.Id; Val = $mEcoNum }
$updatedFile = $vault.DocumentService.UpdateFileProperties(@($FileMID), @($propInstParamArray))

0 Likes

Markus.Koechl
Autodesk
Autodesk

You aren't using VDS, right? If so, I guess you also expect the property written in the file. I found a sample in Powershell in my older treasures that I did not touch for years ;): VDS-Sample-Configurations-2024/VDS-PDMC-Sample/Vault.Custom/addinVault/Menus/ADSK.QS.AdskFilePropPro...



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes

J_Dumont
Advocate
Advocate

No, not using VDS.

 

I failed to mention that I'm using PowerShell with coolOrnage powerJobs and they have an object that I was able to get to work.

 

$updateProp = Update-VaultFile -File $file.'Full Path' -Properties @{'Subject'=$mEcoNum}

 

Thank you for your support!!!

 

0 Likes

Tony_Yates
Advocate
Advocate

Hi J Dumont,

This sounds like something we could use. We are using cool orange. Would you be kind enough to share your code?

 

Thanks

Tony

0 Likes

J_Dumont
Advocate
Advocate

Hi Tony,

 

I created a custom UDP in Vault called, ECO_Number and then assigned this in the Vault Revision Table Settings as shown below.

J_Dumont_0-1700501913846.png

 

Here is the code I use in a powerEvents script.

$mEcoFile = $vault.ChangeOrderService.GetChangeOrderFilesByFileMasterId($file.MasterID)
if ($null -ne $mEcoFile) {
$mEcoNum = $mEcoFile[0].ChangeOrder.Num
Update-VaultFile -File $file._FullPath -Properties @{'ECO_Number'=$mEcoNum}
}

 

FYI..I'm hosting a webinar showing many of the Automation procedures I created with powerJobs and powerEvents and you are welcome to attend. It takes place on 12/14 at 1 pm EST.

The registration for the webinar is https://microcad3d.com/#events

 

0 Likes