AddLink to Custom Object

AddLink to Custom Object

Eli_Dexter
Advocate Advocate
721 Views
1 Reply
Message 1 of 2

AddLink to Custom Object

Eli_Dexter
Advocate
Advocate

I am trying to Create links from File(s) to Custom Object (equivalent to Copying File and pasting as Link to Custom Object) thru Vault API (and PowerVault).

I have found an AddLink method, however, when I am trying to use it:

$vault.DocumentService.AddLink($file.MasterId, "CUSTENT", $custObj.Id, "Test") 

I am getting an error: 

Exception calling "AddLink" with "4" argument(s): "109"

+ $vault.DocumentService.AddLink($file.MasterId, "CUSTENT", $custObj.Id ...

 

What am I doing wrong?

0 Likes
Accepted solutions (1)
722 Views
1 Reply
Reply (1)
Message 2 of 2

Markus.Koechl
Autodesk
Autodesk
Accepted solution

It would be best if you swapped parent/child: A file can be linked to a custom object and listed in the Content view of the Custom Object. The file's Where Used will list the object also if you expand the parent filter.

My VDS sample configuration has (disabled) sample code to link classified components to classes (=Custom Objects):

$link = $vault.DocumentService.AddLink($parentID,"FILE", $childID, "Parent->Child")

parentID = Id of the custom object

"FILE" = the entity type to be linked

childID = the latest file iteration of the file

You can review the full context, including managing to add or update an existing link here: VDS-Sample-Configurations-2024/VDS-PDMC-Sample/Vault.Custom/addinVault/Menus/ADSK.QS.EditFile.ps1 at... 



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes