An extension is a business rule that adds pre-defined behavior to a business object operation and fires as a pre-condition, pre-action, or post-action. When we define an extension, we can identify the parameters passed to the extension when it is executed, and how the extension is made available to other business objects.
For Example, we can use the same custom extension to more than on business object operation and differentiate the functionality or behavior based on the parameter value.
Extensions allows to write a custom function or method for Teamcenter in C or C++ and attach the rules to predefined hook points in Teamcenter.
After we assign an extension to a business object or a property operation so that it is called at a particular point (on a pre-condition, pre-action, base action, or post-action on the object), we must write the implementation code that takes place in Teamcenter when the extension is called.
Use Case Example:
Let us take an use case to understand how the extension works.
In this use case, we have 2 objects - DesignItemRevision and DocumentRevision. They are related using IMAN_specification (Specification) relation. The ask is to copy attributes from DesignItemRevision to DocumentRevision whenever they are related using Specification relation.
Key things to identify,
What is the primary business object
What is the relation business object
What is the secondary business object
Action on which extension has to be execution
Business object operation that suits the extension for the use case
Operation point (Pre-Condition/Pre/Post Action) for the extension based on the use case.
For our use case:
What is the primary business object - Design Item Revision
What is the relation business object - IMAN_specification
What is the secondary business object - Document Revision
Action on which extension has to be execution - During relation creation
Business object operation that suits the extension for the use case - GRM_create
Operation point (Pre-Condition/Pre/Post Action) for the extension based on the use case. - Post Action. Relation has to be successfully created in our use case. we should not copy attributes during relation failures.
Implementation of the use case:
1. Create custom extension in BMIDE:
- Create a new extension in BMIDE.
- In Extension tab, traverse through Project -> Rules -> Extensions
- Right click on Extensions folder -> New Extension Definition.
- In New Extension Definition dialog, type in the Name of the new custom extension and select the Library. Extension will be added to the selected library.
- For the simplicity of this usecase, parameters are not defined. Parameters comes in handy to make the extensions scalable to various scenarios/use cases to work differently based on parameter value.
- Add Availability based on our findings for this use case (from previous section).
Business object name - IMAN_specification
Type - Type
Operation name - GRM_create
Extension point - PostAction
2. Add extension to operations in BMIDE:
- After creating the custom extension, next step is to attach the extension to the business object under operations as defined in availability.
- For our use case, extension has to be attached in specification object in grm_create operation at postaction.
- Select GRM_create operation and under Extension Attachments click Add to add our custom extension in post-action.
- Save the datamodel and deploy the BMIDE package through tem.
3. Coding Custom Extension:
- Last step in the process to code the logic to copy the attribute values.
- In this example we use BMIDE to generate extension psuedo code.
- For coding extension we need to know the arguments (va_list) the extension passes. We can get this information in ITK help. Search with <Operation_name>_msg.
- For GRM_create operation, 5 parameters are passed in va_list which can be read in the code and used for the logic.
- For our use case, we need first 2 parameters. Primary and secondary object.
tag_t tPrimaryObject = va_arg(args, tag_t); tag_t tSecondaryObject = va_arg(args, tag_t);
- Once we get the primary and secondary object, we can build our logic to read and set the attributes as like any other customization. (we haven't showed the code, you can try and let us know if you need any help).
- Build and deploy the library to test the usecase.