Aras Innovator Platform

Generic Methods

Generic Methods are used to perform arbitrary business logic. They can be used to perform any logic you require, and its input Item is up to you. They are called in the IOM with the Innovator.applyMethod(…)
method.

Context Item

The context Item is this
keyword Object in JavaScript and C# and is the Me Object in VB.NET. The XML data for the context Item is the XML submitted as the payload for the request and it may not be valid AML, just well formatted XML. It does not matter it is the input for the Generic Method and can be whatever you want it to be.

Methods are Item Factories

The Generic Method must return an Item or an Error like ‘Item Action’ Methods. Often the result of the Generic Method is some simple text or an HTML fragment. The text can be returned using the Innovator.newResult(text)
method. If the Method needs to return an Error use Innovator.newError(text)
method.

C#

Innovator innovator = this.getInnovator();
return innovator.newResult(“This method was <b>successful</b>.”);
OR
Innovator innovator = this.getInnovator();
return innovator.newError(“This method has <b>failed</b>.”);

C# Example

Innovator innovator = this.getInnovator();
Item item = this.newItem(“User”, “get”);
Item results = item.apply();

int count = results.getItemCount();
if (count<1) return innovator.newError(“No users found.”);

StringBuilder content = new StringBuilder();
content.Append("<table>");

for (int i=0; i<count; ++i)
{
Item user = results.getItemByIndex(i);
content.Append("<tr><td>Login Name:</td><td>");
content.Append(user.getProperty(“login_name”));
content.Append("</td></tr>");
}
content.Append("</table>");
return innovator.newResult(content.ToString());

Methodology

Typically, all you need are simple name/value pairs as input for your Method and those are like Property tags for the Item. The body for the Generic Method is nested inside an <Item>
tag so you can pass a name/value pair as arguments to the Generic Methods like ordinary Property tags.

The Item passed as the context Item can represent any Item you want including fictitious Items. You have the added advantage of continuing to use the IOM API to operate on the context Item Object.