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 Andreas, no, of course I didn´t try that... Many thanks for this one, this version now does the job pretty well:
    Innovator inn = this.getInnovator();
    this.setProperty("keyword_","INSERT");
    Item res = this.apply("MyMainMethod");
    if (res.isError())
    {
        XmlDocument xDoc = new XmlDocument();
        xDoc.LoadXml(res.ToString());
        string faultstring = xDoc.SelectSingleNode("//faultstring").InnerText;
        return inn.newError("Error: " + faultstring);
    }
    return res;
Reply
  • Hi Andreas, no, of course I didn´t try that... Many thanks for this one, this version now does the job pretty well:
    Innovator inn = this.getInnovator();
    this.setProperty("keyword_","INSERT");
    Item res = this.apply("MyMainMethod");
    if (res.isError())
    {
        XmlDocument xDoc = new XmlDocument();
        xDoc.LoadXml(res.ToString());
        string faultstring = xDoc.SelectSingleNode("//faultstring").InnerText;
        return inn.newError("Error: " + faultstring);
    }
    return res;
Children
No Data