How to pass items in applyMethod?

Hi, I have a couple of huge server Methods, that share around 90% of the same code. So I want to unify them into one large Method, and use more compact calling Methods. My current problem is to past the context Item(s) to the main Method. When I call a server Method from a server Method, the selected Items are replaced with the Method item. This is what I have tried so far:
// Method triggered from Lifecycle
string body ="<keyword_>INSERT</keyword_><items_>" + this + "</items_>"; // ???
Item res = inn.applyMethod ("MyMainMethod", body);
return res;
// Main Method
Innovator inn = this.getInnovator();
XmlDocument xDoc = new XmlDocument();
if ((this.getAttribute("type", "") == "Method") & (this.node.SelectSingleNode("items_") != null))
{
  this.node = xDoc.CreateElement(this.node.SelectSingleNode("items_").ToString());
}
string thisItemTypeName = this.getItemByIndex(0).getAttribute("type",""); // will return Method instead of original items
Is it possible to overwrite the context of "this" with the item passed in applyMethod? Thanks for any input! Best regards, Angela
Parents
  • Hi Angela, I do not know if I understood you correctly but maybe this (from Aras Programmer's Guide) could help you: 4.1 Item Actions Extend the Item Class One purpose for Methods is to extend the Item Class. Methods extend the Item Class when they are bound as the related Item for ‘Item Action’ relationships on the ItemType. In the AML the Method name is the action attribute name for the Item tag. <Item type="My ItemType" action="My Method" id="…"/> The Method could be called using the IOM like this (all three examples below are equivalent and are written in C#):
    
    1) Item myItem = this.newItem("My ItemType", "My Method");
    myItem.setID(this.getID());
    Item results = myItem.apply();
    2) Item myItem = this.newItem("My ItemType");
    myItem.setID(this.getID());
    Item results = myItem.apply("My Method");
    3) Item myItem = this.newItem();
    myItem.setID(this.getID());
    myItem.setType("My ItemType");
    myItem.setAction("My Method");
    Item results = myItem.apply();
    
Reply
  • Hi Angela, I do not know if I understood you correctly but maybe this (from Aras Programmer's Guide) could help you: 4.1 Item Actions Extend the Item Class One purpose for Methods is to extend the Item Class. Methods extend the Item Class when they are bound as the related Item for ‘Item Action’ relationships on the ItemType. In the AML the Method name is the action attribute name for the Item tag. <Item type="My ItemType" action="My Method" id="…"/> The Method could be called using the IOM like this (all three examples below are equivalent and are written in C#):
    
    1) Item myItem = this.newItem("My ItemType", "My Method");
    myItem.setID(this.getID());
    Item results = myItem.apply();
    2) Item myItem = this.newItem("My ItemType");
    myItem.setID(this.getID());
    Item results = myItem.apply("My Method");
    3) Item myItem = this.newItem();
    myItem.setID(this.getID());
    myItem.setType("My ItemType");
    myItem.setAction("My Method");
    Item results = myItem.apply();
    
Children
No Data