Retrieving a BOM table of an item in an old revision

Hi all,
if I use this instruciotn (for example)
ITable bomTable = currentItem.getTable(ItemConstants.TABLE_BOM);

it will retrieve the BOM table of the item in its last revision. How can I tell to the script to retrieve the BOM of that item in another revision? For example, if the item is release din rev. 05 I would like to retrieve the BOM it has in revision 02; is it possible?

Add Comment
9 Answer(s)
Best answer

Try This:

IItem currentItem ....
String myRevision = "02";
currentItem .setRevision(myRevision);
ITable bomTable = currentItem.getTable(ItemConstants.TABLE_BOM);
...

with setRevision you can put an IChange instance or the version number.
Once this setRevision, you can got all version information from the item. It is the same operation that you do in the webclient changing the version from the select menu

Agile Angel Answered on February 10, 2016.
Add Comment

Thank you very much Antonio!!

Agile User Answered on February 10, 2016.
Add Comment

Welcome!
I have just updated the snippet with correct variable name 🙂

Agile Angel Answered on February 10, 2016.
Add Comment

Thank you again!
I have another question: how can I retrieve the latest released revision of an item? I use the getRevision() instruction but, if an object has a pending change, it returns the new revision in brackets.
My case is this: If I unrelease a change order I’d like to have the previous revision of the item (i.e. the latest released one), not the one it would have after the release of the change.

Agile User Answered on February 10, 2016.
Add Comment

If you get the Item from the Affected item Tab, you will get always the pending revision if you call getRevision().
You can open the item from the session using the number 

IItem item = (IItem) session.getObject(IItem.OBJECT_TYPE, "P12345");
item.getRevision(); //returns the latest released version.

If you have to get anyway the item from the Affected item tab, you can get the Last Rev field value and set the item revision to it.
for example
ITEM NUMBER           LAST REV        NEW REV
ITEM123                       2                           3

currItemRow : affectedItem
{
currItem.setRevsion(currItemRow.getValue(LASTREV))
//now item is set for version 2.
}

Agile Angel Answered on February 10, 2016.
Add Comment

Thank you so much again Antonio, you solved all my problems! 🙂

Agile User Answered on February 10, 2016.
Add Comment

You are welcome! Please mark your question as answered.maybe can help someone else 🙂

Agile Angel Answered on February 10, 2016.
Add Comment

Antonio, please forgive me for my ignorance, but I can’t find how to mark the question as answered. I don’t see any button to do that.

Agile User Answered on February 11, 2016.
Add Comment

under the arrow to vote down an answer, you as owner of the question should see another button with a check. You can click on this button to mark the answer as best one

Agile Angel Answered on February 11, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.