Differentiate between purge and delete

rated by 0 users
This post has 2 Replies | 1 Follower

Top 50 Contributor
Posts 29
Points 235
zapping Posted: Wed, Jun 9 2010 10:21 AM

Hi,
  When a Part gets deleted i would like the corresponding entry in the Manufacturer Part also be deleted. But for purge this should not happen is there a way to differentiate between the two actions. I added a method to the onBeforeDelete event of Part and included this.

if (this.getAction().ToLower() == "delete") {
    //delete from manufacturer part
    Item manufPart = this.newItem("Manufacturer Part", "delete");
    manufPart.setAttribute("where", "item_number = '" + part.getProperty("item_number") + "'");
    manufPart = manufPart.apply();
    if (manufPart.isError()) {
            return manufPart;
    }
}

But the this.getAction always returns 'purge'.

Any pointers pls.

Cheers,
Zaps.

Top 50 Contributor
Posts 29
Points 235
zapping replied on Wed, Jun 16 2010 6:48 AM

Hi,
  Is there a means to get the instance to the version of the item that will become active when a purge is done on a versionable item.

thanks,
Zaps

  • | Post Points: 5
Top 50 Contributor
Posts 29
Points 235
zapping replied on Wed, Jun 16 2010 9:50 AM

Hi,
Tried this but it returns only the latest one and itemcount also returns 1 when it should be 4.

Item versions = this.newItem("part", "get");
versions.setProperty("config_id", part.getProperty("config_id"));
versions.setAttributeProperty("generation", "condition", "lt " + (Convert.ToInt32(part.getProperty("generation"))-1));
versions.setAttribute("orderBy", "generation");
versions = versions.apply();

Tried with "where" also but strange that does not return any value
versions.setAttribute("where", "part.generation < 4 and part.config_id = '" + part.getProperty("config_id") + "'");

Any tips please.

zaps.

  • | Post Points: 5
Page 1 of 1 (3 items) | RSS