Skip to content

Instantly share code, notes, and snippets.

@cgillis-aras
Last active March 19, 2019 20:11
Show Gist options
  • Save cgillis-aras/c112e17a5c1e4f6201a8f7ff746b6125 to your computer and use it in GitHub Desktop.
Save cgillis-aras/c112e17a5c1e4f6201a8f7ff746b6125 to your computer and use it in GitHub Desktop.
Example of a custom action in Aras Innovator
Innovator inn = this.getInnovator();
Item partToAdd = this;
partToAdd.setAction("add");
string parentPartNumber = this.getAttribute("parent", "");
if (String.IsNullOrEmpty(parentPartNumber))
{
// If no parent is specified, just add the part like normal
return partToAdd.apply();
}
else
{
// If there is a parent, also create a relationship to that parent as part of this add
Item relationshipToParent = inn.newItem("Part BOM", "add");
Item parentPart = relationshipToParent.createPropertyItem("source_id", "Part", "get");
parentPart.setProperty("item_number", parentPartNumber);
relationshipToParent.setRelatedItem(partToAdd);
return relationshipToParent.apply();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment