This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Getting items marked to be removed from an ECR/ECN

Nick - Thursday, April 7, 2011 4:38 PM:

I noticed that when you go to remove a property/field/item from an item list (say a part from an ECR) it doesn't remove it right away, it just italicizes(?) the selected item and doesn't remove it until you save/lock the ECR. Is this list of items marked to be removed saved somewhere that I can get in a before server method to execute code with?



Brian - Thursday, April 7, 2011 5:40 PM:

Hi Nick,

You will want to be in the "onBeforeUpdate" method.

This contains the information going to the server. You can interact with this information before allowing the save to continue or you can reject the save by returning false from the method.

Cheers,

Brian.



Nick - Thursday, April 7, 2011 6:16 PM:

Yea that's what I was thinking it would be. Do you know if the items get flagged somehow, or put into a list to show that they are being deleted onUpdate?



Brian - Thursday, April 7, 2011 7:28 PM:

Hi Nick,

In the method called in onBeforeUpdate you could get at the items be deleted using this code:

Innovator inn = this.getInnovator();
System.Diagnostics.Debugger.Break();
Item delItems = this.getItemsByXPath("//Item");
for ( int i = 0; i < delItems.nodeList.Count; i++)
{
Item tmp = delItems.getItemByIndex(i);
string typ = tmp.getAttribute("type");
if ( typ == "ECR Affected Item" )
{
string act = tmp.getAttribute("action");
if ( act == "delete")
{
      //Code to deal with the items being delete.
}
}
}
return this;

 

 

 This is uglier than I feel it should be but the xPath expressions that I think I should be using are not returning sensisble results.

Bear in mind that at the point you have the items to be deleted you are dealing with an ECR Affected Item which in turn ultimately relates to a Part or Document. You are not dealing directly with the Part or Document.

Cheers,

Brian.



Nick - Tuesday, April 19, 2011 4:04 PM:

Having some issues getting this to work, I've been looking at ECR Affected Item at onBeforeUpdate with vs debugging, and there's no action attribute set when you're trying to remove an item. I tested this with an ECR with just one item on it, and couldn't find even an attribute called action -_-. It would make sense that it would be set in ECR Affected Item but I can't seem to find what to look at, any ideas?



Nick - Thursday, April 28, 2011 11:36 AM:

Ok I managed to get it working, figured I'd post how I did it.

I ended up having it as an onBeforeDelete server method on ECR Affected Item, using the same formula to make the relationship as I used on an ECR, just altering it to assume this is an ECR Affected Item, not an ECR.