Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Assign items to files

4 REPLIES 4
Reply
Message 1 of 5
tmccar
606 Views, 4 Replies

Assign items to files

I have imported 2000 items into Vault Item Master. Is there a way I can assign each item to a file (.dwg) using the API, if I have a database table with the correct mappings?

4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: tmccar

I am new to Vault.

I think you can start from PromoteFiles method of ItemServiceomoteFiles

Message 3 of 5
Anonymous
in reply to: Anonymous

Or start from ReassignComponentsToDifferentItems method of Itemservice.

You can refer to Vault API SDK about use of ReassignComponentsToDifferentItems method.

Message 4 of 5
Redmond.D
in reply to: Anonymous

ReassignComponentsToDifferentItems works well if there is a 1-to-1 mapping between files and items. 

 

I don't recommend using it if you have 1-to-many or many-to-many relationships.  In these cases, you need to have a BOM object on the file.  Once that is done, the PromoteFile call will generate the items with the correct BOM structure.

 



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 5 of 5
Anonymous
in reply to: tmccar

Vault sdk has a sample copied as below.

 

using Autodesk.Connectivity.WebServices;

class VaultSDKSample {    

 public void AssignFileToItem(ItemService itemSvc, Item selectedItem, File selectedFile)    

 {        

     ItemsAndFiles promoteResult = null;        

     Item[] updatedItems = null;       

      try         {           

       // first assign the file to a new item            

       // this example assumes that only 1 item will result from the promote            

        promoteResult = itemSvc.PromoteFiles(new long[] { selectedFile.Id });

            // next reassign the file from the new item to the existing item            

      updatedItems = itemSvc.ReassignComponentsToDifferentItems(             new long[] { promoteResult.ItemRevArray[0].Id },             new long[] { selectedItem.Id });

            // commit the changes            

          itemSvc.UpdateAndCommitItems(updatedItems);        

        }         catch         {             if (updatedItems != null && updatedItems.Length > 0)             {                 long[] itemIds = new long[updatedItems.Length];                 for (int i = 0; i < updatedItems.Length; i++)                 {                     itemIds[i] = updatedItems[i].Id;                 }                 itemSvc.UndoEditItems(itemIds);             }         }         finally         {             if (promoteResult != null)             {                 // clear out the promoted item                 itemSvc.DeleteUnusedItemNumbers(new long[] { promoteResult.ItemRevArray[0].MasterId });                 itemSvc.UndoEditItems(new long[] { promoteResult.ItemRevArray[0].Id });             }         }     } }

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report