Hi Maddy,
If you want to call this Method whenever the generation of an Item is increased, you can call it from an onAfterVersion server event on the ItemType.
If you want to call this Method for every increment of the "major_rev" property, there is no built in event to handle this. However, you can call the following Methods from an onBeforeVersion/onAfterVersion server event to check if the major_rev has been increased between them.
onBeforeVersion:
Innovator inn = this.getInnovator();
// Get the major_rev before the version
Item myPart = inn.newItem("Part", "get");
myPart.setID(this.getID());
myPart.setAttribute("select", "major_rev");
myPart = myPart.apply();
string prevRev = myPart.getProperty("major_rev");
RequestState.Add("prevRev", prevRev); // Add value to SessionState
return this;
onAfterVersion:
Innovator inn = this.getInnovator();
string prevRev = (string)RequestState["prevRev"];
// Get the most recent version of this item
Item newItem = inn.newItem("Part", "get");
newItem.setProperty("config_id", this.getProperty("config_id"));
newItem.setProperty("is_current", "1");
newItem.setAttribute("select", "major_rev");
newItem = newItem.apply();
string currRev = newItem.getProperty("major_rev");
// If the major_rev's are not equal, the item has been versioned
if (prevRev != currRev)
{
// Put logic here
}
return this;
Any logic you want to run when an item is versioned can be placed in the if statement in the onAfterVersion event.
Chris
_______________________
Christopher Gillis
Aras Labs Software Engineer