angela
8 years agoCatalyst II
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