Forum Discussion
angela
8 years agoCatalyst II
Hi Andreas,
thanks for your help! Your code basically works, but I still have some trouble to hand over the complete Item that calls the Method:
// Calling Method
Innovator inn = this.getInnovator();
Item myItem = this.newItem(this.getAttribute("type"), "MyMainMethod");
myItem.setID(this.getID());
myItem.setProperty("keyword_","INSERT");
Item results = myItem.apply();
if (results.isError())
{
return inn.newError("Error while Insert Data. " + results);
}
return results;
// Main Method
Innovator inn = this.getInnovator();
string thisItemTypeName = this.getItemByIndex(0).getAttribute("type",""); // work! will return type of calling Item instead of Method
// Parameters passed with Method call
string keyword = this.getProperty("keyword_","invalid"); // works
if (keyword == "..."){}
// Get properties from calling Item
int count = this.getItemCount(); // don´t work
string pn = this.getItemByIndex(0).getProperty("item_number", "empty"); // don´t work, will always be empty, as "this" doesn´t contain the complete original Item.
It would be possible to extend the calling Method to handover more properties. But this would make the calling Method more complex. One alternative is to extend the Method call so it contains the original Item:
myItem.setProperty("myitem_", this);
But I am not sure if passing "this" is really the best solution. This will move around a lot of data, as the Method shall apply to multiple items.