Remove certain property values onAfterVersion an Item

Hi, this one sounds like an easy to do task, but it´s somehow not. I want to reset certain ERP related properties after creating a new generation of a Part. My idea was to use a simple onAfterVersion Method for this task:
innnovator inn=this.getInnovator();

string partConfigId=this.getProperty("config_id");
string itemType=this.getType();

// Get newest version of this Part
Item newPart = this.newItem("Part","get");
newPart.setProperty("config_id", this.getProperty("config_id"));
newPart.setProperty("is_current","1");
newPart.setAttribute("select", "id");
newPart = newPart.apply();
if (newPart.isError())
{
    return inn.newError("Keine neue Revision gefunden: " + newPart.getErrorDetail() ); 
} 
string newId = newPart.getID(); // works!

// Edit newest version of this item
Item editPart = inn.getItemById("Part", newId);
editPart.setAction("edit");
editPart.setAttribute("doGetItem", "0");
editPart.setProperty("erp_is_matched","0");
editPart.removeProperty("erp_variant");
editPart = editPart.apply();
Unfortunately this code doesn´t update any value of the newest Part version. Even applySQL or grant of special permission doesn´t change anything. My only remaining idea is to customize related Methods like PE_CreateNewRevision and the transition handlers...again.. Is there some more general option available to change values after versioning an Item programatically? Best regards, Angela
Parents Reply Children
No Data