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.
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
- Login as admin
- In the TOC, navigate to Administration > RelationshipTypes
- 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
- In the Grid Events tab, add a relationship to the Method you want to be called
- 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.
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.
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.
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.
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.