Community
Vault Forum
Welcome to Autodesk’s Vault Forums. Share your knowledge, ask questions, and explore popular Vault topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API - UpdateItemsFromFiles

10 REPLIES 10
Reply
Message 1 of 11
tommam
286 Views, 10 Replies

API - UpdateItemsFromFiles

Using PS2008, I'm trying tp update the properties of an item (like Title and Description) from the file after the file has been reassigned. Here's the (VB.Net) code:

newRev = itmSvc.EditItem(realItem.RevId)
updatedItems = itmSvc.ReassignComponentsToDifferentItems( _
New Long() {promoteResult.ItemRevArray(i).Id}, New Long() {newRev.Id})
itmSvc.UpdateAndCommitItems(updatedItems)
'Update properties from the file
newRev = itmSvc.EditItem(updatedItems(0).RevId)
updateResult = itmSvc.UpdateItemsFromFiles(New Long() {newRev.RevId})
itmSvc.UpdateAndCommitItems(New Item() {newRev})

The Reassign works fine and the rest of the code runs through without error, but the properties (specifically Title and Description) are not updated. If I go into PS and manually update the item, then the properties are updated to match the file's settings.

Any idea why my code isn't working, but the maual process does work?

Thanks!
10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: tommam

The title and description get set based on what the values are on the Item
object when the commit function is called. So for your last line of code
you should be passing in updateResult.ItemRevArray instead of newRev.

If that doesn't work, you will have to explicity set the 'Title' and
'Detail' properties on the Item object before you pass it in to the commit
function.

Only a few of the Item properties can be updated this way. The
documentation for the commit functions tell you which properties those are.


Doug Redmond
Software Engineer, Autodesk Inc.
Message 3 of 11
tommam
in reply to: tommam

Okay, I tried passing in updateResult.ItemRevArray instead of newRev, but when I ran it, updateResult.ItemRevArray was set to Nothing!

Does this mean the call to UpdateItemsFromFiles didn't work?
Message 4 of 11
Anonymous
in reply to: tommam

I found the problem. You should not be calling EditItem before calling
UpdateItemsFromFiles. Just delete that line of code and it should work
fine.

I would expect UpdateItemsFromFiles to throw an error if it was passed
incorrect data. I'll log a defect on it.


Thanks,
Doug Redmond
Software Engineer, Autodesk Inc.
Message 5 of 11
tommam
in reply to: tommam

Thanks Doug, that did it.
Message 6 of 11
tommam
in reply to: tommam

I ran into a case where the code fails. I have an item "ABC" that has item "XYZ" in it's BOM. There is no file associated with this item. I also have a file called "ABC". When I promote this file, and reassign the resulting item to the item named "ABC", it works fine. But then when I call UpdateItemsFromFiles, the updateResult I get has one entry in it's ItemRevArray, the item for "XYZ"! When I try to call UpdateAndCommitItems on this ItemRevArray, it throws an error because "XYZ" is not in an edit state. Any ideas?

Thanks.
Message 7 of 11
Anonymous
in reply to: tommam

Does file ABC have any BOM data associated with it? If so, does the BOM
look like?
You can call GetBOMByFileId in the Document Service if you need to check.

When doing a Promote or an UpdateFromFiles operation, the BOM data becomes
the template for the created/updated items. So if the BOM data doesn't
match the file's data, you could get some very strange results when creating
the items.

Another thing to check is the 'StatusArray' property on the return value
from UpdateItemsFromFiles.


Doug Redmond
Software Engineer, Autodesk Inc.
Message 8 of 11
tommam
in reply to: tommam

Doug,

Yes, file ABC does have BOM data associated with it. In some cases it will match the item's BOM, sometimes it will be different. But I do a promote and a reassign before I try to update the properties, so after I do the reassign, the item's BOM should match the file's BOM. Are you saying that I may get strange results from the reassign?

Thanks,
Tom
Message 9 of 11
Anonymous
in reply to: tommam


When you do the promote/reassign, the promoted Item
is just temporary.  It should be deleted when you are finished with the
reassign.

 

The reassin operation only moves over the item/file
link.  It doesn't move over any of the data from the promote Item.  So
at the end of the assign, the pre-existing item should be exactly the same
except for the new file link.

 

If the file's BOM doesn't match the item that the
file is now associated with, it is possible for the update to have strange
results.

 

In any event, the file's BOM is a very big factor
when doing promotes or updates.  So that should be one of the first things
to check if you are getting strange results.

 

 

Doug Redmond

Software Engineer, Autodesk Inc.

 

 
Message 10 of 11
tommam
in reply to: tommam

So, when in ProductStream, if I right-click an item and say "Update...", it must be doing a lot more than just calling 'UpdateItemsFromFiles'. Is there any documentation that describes this process in detail? All I have is the 'Vault API Help' file and there's not much detail in that. Thanks again.
Message 11 of 11
Anonymous
in reply to: tommam


Email me directly on this topic: doug.redmond AT
autodesk.com

 

Thanks,

Doug Redmond

Software Engineer, Autodesk
Inc.

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

Post to forums  

Autodesk Design & Make Report