So - I haven't posted on this blog in forever, but it seems like the best place for this.
Unless you're some kind of regular reader from the mid-2000s and I'm still in your feed - I'm guessing that you found me by googling something like:
How the @#$#%#% do I get Autodesk Vault Items to update their secondary links to files with the Vault API!?!??!
After struggling with this for a while, I figured I would share my knowledge gained so that you don't have to bang your head on the table as long as I did.
Here's the trick:
You need to call a method called ItemService.PromoteComponentLinks.
Here's the code:
wsm.ItemService.UpdatePromoteComponents(new long[] { item.RevId }, ItemAssignAll.Default, false);
DateTime timestamp;
GetPromoteOrderResults promoteOrder =
wsm.ItemService.GetPromoteComponentOrder(out timestamp);
if (promoteOrder.PrimaryArray != null && (promoteOrder.PrimaryArray.Length>0))
{
wsm.ItemService.PromoteComponents(timestamp, promoteOrder.PrimaryArray);
}
if (promoteOrder.NonPrimaryArray != null && (promoteOrder.NonPrimaryArray.Length>0))
{
wsm.ItemService.PromoteComponentLinks( promoteOrder.NonPrimaryArray);
}
ItemsAndFiles itemsAndFiles =
wsm.ItemService.GetPromoteComponentsResults(timestamp);
newItem = itemsAndFiles.ItemRevArray[0];
wsm.ItemService.UpdateAndCommitItems(new Item[] { newItem });
How did I figure it out? I broke down and turned on Fiddler to watch the traffic between my Vault Explorer and the server. It's actually a pretty nice hack - thank you to whomever on the Autodesk side added what the currently running command was to the URL query.
Anyway - I'm hopeful that your googling finds the above results, instead of various articles and support forum posts from Doug and Wayne from the beginning of this decade :).
Tuesday, September 24, 2019
A quick note for Vault API developer posterity: PromoteComponentLinks
Posted by Matt Mason at 7:10 PM 0 comments
Subscribe to:
Posts (Atom)