Method to get Custom Entity Properties thru API

Method to get Custom Entity Properties thru API

Eli_Dexter
Advocate Advocate
831 Views
10 Replies
Message 1 of 11

Method to get Custom Entity Properties thru API

Eli_Dexter
Advocate
Advocate

How do I get Custom Object Properties in Powershell with PowerVault using API call.

I have looked thru SDK documentation and could not find in CustomEntityService any Methods that let me get the Properties of the Custom Object and their Values.

Interestingly, there is UpdateCustomEntity method to update Custom Objects. But before Update  I would like to check if update is required.

 

Thanks

0 Likes
Accepted solutions (2)
832 Views
10 Replies
Replies (10)
Message 2 of 11

dave_taylor
Advocate
Advocate

If you are using coolOrange powerVault, you can get the file like this and then get the property needed:

 

# get the file

$file = Get-VaultFile -File '$/Designs/Part01.ipt'

 

# get the property needed
$propCustom = $file.'CustomPropName'


Check here: https://doc.coolorange.com/projects/powervault/en/stable/code_reference/commandlets/

 

Items are a similar method. Check the commandlet reference with the link above.


Dave Taylor
MCAD Solutions Engineer
Hagerman & Co.


Autodesk Certified Instructor - Platinum



*Likes to this post are appreciated if the information I have shared is helpful to you and/or others...
**Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.
0 Likes
Message 3 of 11

Eli_Dexter
Advocate
Advocate

The question was not about file properties but Custom Object properties. Unfortunately, CoolOrange practically does not support Custom Objects.

0 Likes
Message 4 of 11

Markus.Koechl
Autodesk
Autodesk
Accepted solution

You can retrieve properties of custom objects as shown here: 

#retrieve property value given by displayname from Custom Object (ID)
function mGetCustentPropValue ([Int64] $mCentID, [STRING] $mDispName)
{
	$PropDefs = $vault.PropertyService.GetPropertyDefinitionsByEntityClassId("CUSTENT")
	$propDefIds = @()
	$PropDefs | ForEach-Object {
		$propDefIds += $_.Id
	} 
	$mPropDef = $propDefs | Where-Object { $_.DispName -eq $mDispName}
	$mEntIDs = @()
	$mEntIDs += $mCentID
	$mPropDefIDs = @()
	$mPropDefIDs += $mPropDef.Id
	$mProp = $vault.PropertyService.GetProperties("CUSTENT",$mEntIDs, $mPropDefIDs)
	$mProp | Where-Object { $mPropVal = $_.Val }
	Return $mPropVal
}


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 5 of 11

Eli_Dexter
Advocate
Advocate
Accepted solution
Thanks
0 Likes
Message 6 of 11

J_Dumont
Advocate
Advocate

Hi Markus,

 

I am trying to use the code in your example but getting errors. Any help would be greatly appreciated.

The code needs to retrieve a UDP from the custom object called "RTE_Creator." In this case, it's an email that I will use to send an email.

Here's my function:

#retrieve property value given by displayname from Custom Object (ID)
function mGetCustentPropValue ([Int64] $mCentID, [STRING] $mDispName)
{
	$PropDefs = $vault.PropertyService.GetPropertyDefinitionsByEntityClassId("CUSTENT")
	$propDefIds = @()
	$PropDefs | ForEach-Object {
		$propDefIds += $_.Id
	} 
	$mPropDef = $propDefs | Where-Object { $_.DispName -eq $mDispName}
	$mEntIDs = @()
	$mEntIDs += $mCentID
	$mPropDefIDs = @()
	$mPropDefIDs += $mPropDef.Id
	$mProp = $vault.PropertyService.GetProperties("CUSTENT",$mEntIDs, $mPropDefIDs)
	$mProp | Where-Object { $mPropVal = $_.Val }
	Return $mPropVal
}
        elseif ($customObject._NewState -eq "Approved" -and $customObject._State -eq "Review"){
            $subject = "An RTE State was Changed: "
            $body = "An RTE was just Approved: " + $RTENumber
            $RTECreatorEmail=mGetCustentPropValue($customObject, "RTE_Creator")

Here's the error

 

J_Dumont_0-1739410333803.png

 

 

0 Likes
Message 7 of 11

Markus.Koechl
Autodesk
Autodesk

@J_Dumont, you need to hand over the custom objects Id, not the custom object. 

$RTECreatorEmail=mGetCustentPropValue($customObject.Id, "RTE_Creator")


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 8 of 11

J_Dumont
Advocate
Advocate

Hi Markus,

 

My apologies. That's what I tried first, and I got the same error.

 

        elseif ($customObject._NewState -eq "Approved" -and $customObject._State -eq "Review"){
            $subject = "An RTE State was Changed: "
            $body = "An RTE was just Approved: " + $RTENumber
            $RTECreatorEmail=mGetCustentPropValue($customObject.Id, "RTE_Creator")

J_Dumont_0-1739447749614.png

I am able to show I have a value for $CustomObject.Id as shown below.

J_Dumont_1-1739448254944.png

J_Dumont_2-1739448280840.png

 

 

 

 

0 Likes
Message 9 of 11

Markus.Koechl
Autodesk
Autodesk

I wonder how the error could be the same if $mCentID is the custom entity (object) or the ID (int64). 



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 10 of 11

dave_taylor
Advocate
Advocate

If you are using powerShell, send the variables to the function like this:

 

$RTECreatorEmail = mGetCustentPropValue $customObject.Id "RTE_Creator"

 

Don't use the parenthesis when calling the function with variables. I tried this and it works as it should for you...


Dave Taylor
MCAD Solutions Engineer
Hagerman & Co.


Autodesk Certified Instructor - Platinum



*Likes to this post are appreciated if the information I have shared is helpful to you and/or others...
**Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.
0 Likes
Message 11 of 11

J_Dumont
Advocate
Advocate

Hi Dave,

 

Yes, your solution worked great.!!

 

Thank you both for replying so quickly.