Relationship grids are a critical component of the Aras Innovator web client. By creating custom relationship grid events, you can handle business logic that extends beyond the context item. The sample code and use cases below can help you make the most of this common control.

Definitions

In this post, we'll use the following terms to describe the Aras data model.

Configuring A Relationship Grid Event

You can add a relationship grid event by following the steps below

  1. Login as admin
  2. In the TOC, navigate to Administration > RelationshipTypes
  3. Search for and open the RelationshipType you want to set an event on
    • The code samples in this blog post were written against the Part BOM RelationshipType
  4. In the Grid Events tab, add a relationship to the Method you want to be called
  5. Set the Event for when this method will be called
    • OnInsertRow – is called when a new relationship is added to the grid
    • OnSelectRow – is called when a user clicks on a row in the grid
    • OnDeleteRow – is called when a user deletes a relationship from the grid

Update the Related Item

One common use case is the ability to ensure that some property on the Related Item is set to equal another property on the Source Item. The sample below shows how you can achieve this data synchronization by using the example of ensuring that the designated user of the child is the same as the designated user of the parent.

gist.github.com/…/26ccd27810cc574b949965281bf43792

Update the Relationship Item

There is some data that exists on the Relationship Item directly such as the quantity. This example demonstrates how you can configure a default value to be set for the quantity of a relationship.

gist.github.com/…/0c1b2e9ddd13ab533adcdc97917461f2

Update the Source Item

Occasionally, there is data on a Related Item that would be beneficial to persist on the Source Item. You can see how to synchronize data from child to parent in the example below.

gist.github.com/…/648abcb69d54d385eb99a1a13fb5f894

Add a Relationship to the Source Item

When manipulating data in the relationship grid, it can sometimes make sense to add entirely new relationships programmatically. The sample below walks you through how to consolidate all of the Documents of a Related Item onto the Source Item.

gist.github.com/…/ddfe9c67e8cbc0898eb30feff7f299a1

Note: When using this method, users will need to save the parent item before trying to open the newly related Documents from the grid.

Check Picked or Created Item

When adding relationships, users can typically either pick an existing Related Item or create a new one. When you want to handle these two cases differently, you can use the example below to check how the relationship has been added.

gist.github.com/…/f9abeaf1711b158ccfbaccb72f5db1b3


LOOKING FOR MORE ARAS INSPIRATION?

Subscribe to our blog and follow @ArasLabs on Twitter for more helpful content! You can also find our latest open-source projects and sample code on the Aras Labs GitHub page.