Building a Relationship Structure
Copy
It is possible to define a Relationship from the context item that can go either up or down the data structure. ‘Down’ refers to a relationship direction starting from the Item representing the source side of the relationship and following the related content to the related Item. ‘Up’ by contrast refers to a relationship direction starting from the Item representing the related side of the relationship and following the related content to the source Item. It is also possible to set up a recursive structure, such as the Part --> Part BOM --> Part, to reuse the same logic for multiple levels. The following procedures show how to expand the query both up and down for a Part Query and introduces recursion.
Building a Downward Relationship Structure
Right-click on the Part Context Item and select Add Related Item --> Using Relationship.
Figure 8.
Select the Relationship to include in the structure. In this case, select BOM, check Include Related and click Add.
Figure 9.
The query now looks like shown in figure 10. Note that the Part_1 alias is assigned to the related Part Query Element in the list.
Figure 10.
Right-click the Part Context Item and click Add Related Item --> Using Relationship. In this case, click while pressing Ctrl to select Documents and CAD Documents. Select Include Related.
Figure 11.
Right-click on the top Context Item and select Add Related Item --> Using Item Property. Select an Item Property to add to the query structure. In this case, select created_by_id.
Figure 12.
Use the following procedure to specify the desired Properties for each new element in the Query Definition:
NoteOptionally, you can also set Order By settings as well.For [created_by_id] User, specify the following properties:
Item IDFirst NameLast NameLogin Name
For [Relationship] Part CAD, specify the following property:
Sequence
For [Related] CAD, specify the following properties:
idDocument NumberNameState
For [Relationship] Part Document, specify the following property:
Sequence
For [Related] Document, specify the following properties:
idDocument NumberNameState
Change the Alias on the CAD Documents element to “Part CAD”:
Right-click CAD Documents and click Change Alias.
Figure 13.
Enter Part CAD as the name and click the check mark.
Figure 14.
- Use the same procedure to change Documents Relationship to Part Document.
- Use the same procedure to change User Relationship to Part Created By.
- Save the Query Definition.
Building an Upward Relationship Structure
Right-click the top Part element and click Add Related Item --> Using Referencing Item.
Figure 15.
Select an appropriate Referencing item from the structure. In this case, select Simple MCO Part.
Figure 16.
Right-click the Simple MCO Part element and click Add Related Item --> Using Item Property to select source_id.
Figure 17.
Set Selected Properties on the Simple MCO element to:
idMCO NumberStatusDate Originated
- Save the Query Definition.
Adding a Recursive Call Structure
Recursive structures can reuse sections of the already defined queries. The following example shows how to set up a recursive call for the Part --> Part BOM --> Part relationship structure.
Right-click on the top-level Part element and add the Part BOM --> Part structure.
Figure 18.
For the BOM element, select the following properties:
SequenceQuantityrelated_id
Right-click on the child Part element and click Reuse Query Element Definition.
Figure 19.
Select the top-level Part element and click Add.
Figure 20.
- Save the Query Definition item.
The child Part item now includes a search for the same elements as the top-level Part, including CADs, Documents, other Parts, etc. It also includes the same Properties and Order By logic as specified above.