Windchill REST Services > Windchill REST Services Domain Capabilities > Customizing Domains > Extending Domains > Adding Custom Navigation Between Entities in PTC Domains
Adding Custom Navigation Between Entities in PTC Domains
A PTC domain can be extended to have new navigation between entities in a PTC domain. For example, the Product Management domain, does not provide any navigation between Part entities to show parts that are alternates of each other. To provide this navigation, customizers must extend the Product Management domain. To add Alternates navigation between Part entities in the Product Management domain, the customizers mirror the ProdMgmt domain folder structure in the custom configuration path. Then create the PartsExt.json file to add custom configuration. In the JSON file, under extends property, add the PTC domain entity which you want to extend. In the navigations property, add the new navigation. Apart from providing the configurations in the .json file, customizers must also provide the programming logic to create the target entity set while navigating from the source to target entity. This is done in the .js file corresponding to the entity, in this case, PartsExt.js file. Perform the following steps to add custom navigation between entities:
1. In the custom configuration path, create the following folder structure for the Product Management domain at <Windchill>/codebase/rest/custom/domain/:
ProdMgmt
<version>
entity
2. Create the PartsExt.json file at <Windchill>/codebase/rest/custom/domain/ProdMgmt/<version>/entity and add the following content in the file:
{
"extends": "Part",
"navigations": [
{
"name": "Alternates",
"target": "Parts",
"type": "Part",
"isCollection": true,
"containsTarget": true
}
]
}
3. Create the PartsExt.js file at <Windchill>/codebase/rest/custom/domain/ProdMgmt/<version>/entity and implement the following hooks:
getRelatedEntityCollection—The hook returns the following information:
1. Gets the alternate part entities from the source entities.
2. Puts the alternate part entities in an entity collection.
3. Returns the entity collection in a map.
isValidNavigation—The hook returns the following information:
1. Checks if the navigation being carried out is Alternates. If not, it returns null so that the framework can continue processing other navigations.
2. Gets the source part.
3. Navigates to the target part.
4. Verifies that the target part is the same as specified in the input.
5. Returns true or false to indicate the success of the validation.
Many of the hooks have been implemented in PTC provided domains. For code examples of hook implementations, you can see their implementations in any of PTC provided domains.
After the configuration, when you visit the metadata URL for Product Management domain, the Alternates navigation is available for the Part entity. You can navigate from a part to get its alternate parts.
Was this helpful?