Creating Custom Item Keyed Names

Overview

When an ItemType is created in Aras Innovator, the administrator has the option to configure an item keyed name using the Keyed Name Order setting on any item property. Keyed names are used in system messages to refer to the Item ( e.g Part Number or Part Name). If no keyed name for an ItemType is specified, a unique, internal id is used.

For example, the standard Document ItemType uses the item_number property as the keyed name for each Document item created in the system:creating-custom-item-keyed-names-1

So that when a Document is created, the item_number becomes the keyed name:

creating-custom-item-keyed-names-2

Creating Custom Keyed Names

There may be cases where an administrator needs to create a custom keyed name based on some external property values or as a result of a calculation. A reserved Server Event named GetKeyedName is available to allow a keyed name to be generated programmatically.

For this example, the administrator would like the keyed name to be assigned to the value of the item_number property AND the name of the Assigned Creator identity selected by the creator of the Document item:

creating-custom-item-keyed-names-3

The Assigned Creator is defined as the owned_by_id (type Item) property on the Document ItemType. If the owned_by_id property is selected as a Keyed Name Order property on the ItemType the internal id of Peter Smith appears as the keyed name which is not the desired result.

Create Server Method

First a Server Method is created to obtain the internal id and retrieve the identity name. Then the keyed_name property is assigned programmatically as shown in the example below:

//GET THE VALUES OF THE ITEM_NUMBER AND OWNED_BY_ID PROPERTY
string owner_id = this.getProperty("owned_by_id","");
string dnum = this.getProperty("item_number");
if (owner_id!="")
{
//RETRIEVE THE NAME OF IDENTITY
Item i = this.newItem("Identity", "get");
i.setAttribute("select", "name");
i.setID(owner_id);
i=i.apply();
string name=i.getProperty("name","");

//ASSIGN THE KEYED NAME TO DOC NUM AND OWNER
this.setProperty("keyed_name", dnum + " " + name);
}
else {
//IF NO OWNER JUST USE DOC NUM
this.setProperty("keyed_name", dnum);
}
return this;

Assign Server Method to GetKeyedName Server Event

The Method above is then assigned to the Document ItemType Server Event:

creating-custom-item-keyed-names-4

Final Result

When a new Document item is created or edited the custom keyed name is applied.

creating-custom-item-keyed-names-5

Leave a Reply