origam.com

How to use filtered relationship?

Requirement

I need to create a tab under the entity Repair Order which would show the History of the engine in the service company. This is paired using Serial Number column. In the History I would like to filter out the current Service Repair Order.

What I did

I have a relationship RepairOrderHistory

and I wanted to put there Filter Reference GetNotId which could filter out the current Repair Order. But I don’t know how can I pass the parameter RepairOrderHistory_parId into the relationship from the main RepairOrder?

Question:

Is it possible to use Filtered relationship this way? How can I pass the parameters into relationship query?

Relationship filters are limited to the child entity. The only way how to connect the two entities is using the equality operator using the column pair (master.Id = detail.refMasterId). The main use case is that you only want some of the records from the related entity, based on its values.

Thank you Tomáš.

Ok, so Filtered relationship could be used for example to filter data into different “Tabs” on the screen based on Constant Values or default parameters if I understand it well. So there is no way to pass to the Data Structure dynamic filter based on certain values from the parent.

Solution:

In my case I resolved that using View which connected RepairOrder and other RepairOrder using column Serial Number and excludes relationship to itself.

...
RepairOrder ro INNER JOIN RepairOrder roh ON ro.SerialNumber = roh.SerialNumber and ro.Id <> roh.Id

In Origam Model:

  1. I configured view using Deployment Script Generator (option Missing in Model)
  2. I added relationship from RepairOrder entity into V_RepairOrderHistory (roh.refRepairOrderId = ro.Id)
  3. I added relationship from V_RepairOrderHistory into RepairOrder (roh.refHistoryRepairOrderId = ro2.Id)
  4. Into Data Structure I added Cascade RepairOrder → (Normal RelationType) → V_RepairOrderHistory → (inner join) → RepairOrder
    • This allows me to now add as many fields from RepairOrder entity only in model and no need to modify view

Note

Other option could be to have all fields for history in view and have just relationship RepairOrderV_RepairOrderHistory. May be there could be easier manipulation with the entity. But I wanted to use existing structure and configurations of fields from Entity RepairOrder.