Special AML Actions

In addition to the standard actions like Add, Unlock, Update, Delete, etc, Aras also provides a number of useful special actions OOTB that can be called through AML. In this blog post, we'll go over what some of these actions do and how to format the AML to use them. For a full list of actions available through AML we recommend checking out this wiki created by Eric Domke, a member of the open Aras community. If you want to follow along and try out the examples in this blog, check out how to apply AML queries directly against the server.

GetItemRepeatConfig

This action performs a recursive query to return multiple levels of an Item->Relationship->Item structure. The most common way this action is used is to return Part->Part BOM->Part data from a top-level assembly Part. The basic structure of this AML will look like below.

<AML>
  <Item type="Part" select="name,item_number,id" action="GetItemRepeatConfig" id="YOUR_PART_ID">
    <Relationships>
      <Item type="Part BOM" select="related_id,quantity" repeatProp="related_id" repeatTimes="10"/>
    </Relationships>
  </Item>
</AML>

You'll notice that there are two attributes on the relationship Item node that are unique to this action: repeatProp and repeatTimes. The repeatTimes attribute specifies how many times the recursive query should be performed. A value of '0' in this attribute will cause the recursive query to continue until the last item in the structure is found. The repeatProp attribute specifies what property to perform the recursive query on. Typically, this action will be used for relationships, so the repeatProp will almost always be "related_id".

getItemNextStates

This action can be run on an Item that has a Life Cycle associated with it to quickly return what the next possible states in the life cycle are. This action is especially useful for validation if you have any code that programmatically promotes an item to another life cycle state.

<AML>
  <Item type="YOUR_ITEM_TYPE_NAME" action="getItemNextStates" id="YOUR_ITEM_ID/>
</AML>

This AML structure is very simple as it just requires the ID and ItemType of the item you're working on.

PE_GetRelatedParts

This action is used to perform reverse lookup queries such as getting the Assembly Parts that a child part belongs to. This action is included in the Product Engineering (PE) application which comes standard in almost all installations of Aras Innovator; however, this action can be used with any ItemType including those outside of the PE application.

<AML>
  <Item type="Part" select="item_number" action="PE_GetRelatedParts" id="YOUR_PART_ID" resolution="Version">
    <Relationships>
      <Item type="Part BOM">
        <source_id>
          <Item type="Part"/>
        </source_id>
      </Item>
    </Relationships>
  </Item>
</AML>

For this action, the structure of the AML is primarily what drives the query. There is a required unique attribute in this action called resolution that you can pass in a value of "Version" for as in the example above.

Also note that unlike the two other special actions we've mentioned in this blog, PE_GetRelatedParts is just a Method inside of Aras Innovator. You can also check out our previous post to see how you can use your own custom Methods inside of your AML queries.

Using this Action in a Relationship Tab

The Related Parts relationship tab on the Manufacturer Part ItemType is actually a bit of misnomer in that it displays any parent Parts that have a relationship to that Manufacturer Part. This relationship tab uses a special view that's powered by the PE_GetRelatedParts action, and you can use this view for your own relationships as well.

If we login as an administrator and navigate to TOC > Administration > RelationshipTypes, we can open the Manufacturer Part Part relationship. Here, we can see that a special view has been set in the Relationship View tab. This will override the default relationship grid with whatever alternate view you specify here.

We can see that this view is pointing to a file called ReverseItemsGrid.html. If you look inside this file, you'll see it's a specially formatted grid that's populated by a query using PE_GetRelatedParts. The Parameters field represents the arguments that will be used to run the query.

'ITName='+itemTypeName+'&itemID='+itemID+'&reverseITName=Part&reverseRelationshipName=Part AML'

There's four parameters here that are specified which we can map into the AML like below. 

<AML>
  <Item type="ITName" select="item_number" action="PE_GetRelatedParts" id="itemID" resolution="Version">
    <Relationships>
      <Item type="reverseRelationshipName">
        <source_id>
          <Item type="reverseITName"/>
        </source_id>
      </Item>
    </Relationships>
  </Item>
</AML>

Two of these parameters are set in such a way that they will be automatically populated based on the Item that the user is currently viewing: 'ITName='+itemTypeName+'&itemID='+itemID+'. This means that for most use cases, the only parameters you'll need to change will be reverseITName and reverseRelationshipName. For example, we could add a new relationship to Part that allows Users to see what Assemblies the Part they're viewing is in. If we did this, our Parameters for this RelationshipView would be as follows.

'ITName='+itemTypeName+'&itemID='+itemID+'&reverseITName=Part&reverseRelationshipName=Part BOM'

Conclusion

All the actions in this blog post are used in the OOTB functionality of Aras Innovator and have been exposed via AML for your convenience. If you have any experience using these actions before, please share your story in the comments!


Anonymous