Customizing DPM > Customizing Services
Customizing Services
You can customize the services provided in the PTC building blocks to implement your own logic. This involves creating a new building block that extends from the PTC building block, and overriding the service on the manager Thing for your new building block. The services in a building block can be viewed on the Services page of the manager Thing for the building block.
Keep in mind the following when customizing services:
Changing service code can result in services that are long running or require intense computing, resulting in performance degradation.
As a best practice, customize back-end services rather than user interface-related services.
Customizing a Service
To customize a service, complete the following steps:
1. Determine which building block includes the service that you want to customize. This is easily determined from the name of the manager Thing where the service is found. For example, if the service is on the PTC.StatusImpl.Manager Thing, it is part of the PTC.StatusImpl building block.
2. Create a new building block that extends from the PTC building block which includes the service that you want to customize.
To create your new building block, complete the following steps:
a. Create a new project. Use a unique prefix for your project, such as your company name. The PTC prefix is reserved for entities delivered by PTC. For this example, create a project named MyCompany.StatusImpl. For each new Thing Template, Thing, or other entity that you create for this building block, add your new project as the Project value on the General Information page for the entity.
b. Create an entry point Thing Template in your project that uses the entry point Thing Template from the PTC building block as its Base Thing Template. For this example, name the new Thing Template MyCompany.StatusImpl.EntryPoint_TT, and use PTC.StatusImpl.EntryPoint_TT as its Base Thing Template.
c. Create a new Thing in your project that uses the Thing Template created in step 2.b as its Base Thing Template. For this example, name the new Thing MyCompany.StatusImpl.EntryPoint.
d. Create a new Thing Template in your project that uses the manager Thing Template from the PTC building block that you are extending from as its Base Thing Template. For this example, name the new Thing Template MyCompany.StatusImpl.Manager_TT and use PTC.StatusImpl.Manager_TT as its Base Thing Template.
e. Create a new Thing in your project that uses the Thing Template created in step 2.d as its Base Thing Template. For this example, name the new Thing MyCompany.StatusImpl.Manager and use MyCompany.StatusImpl.Manager_TT as its Base Thing Template.
3. Add any configurations from the manager Thing from the original UI building block to the manager Thing for your new building block.
a. Navigate to the manager Thing that you created in step 2.e, in this example MyCompany.StatusImpl.Manager.
b. Under Configuration, add the same configurations that are found on the Configuration page for the manager Thing of the original building block, in this example, PTC.StatusImpl.Manager.
4. Register the manager Thing of your new building block as the manager to use instead of the manager from the PTC building block that your building block extends from.
a. Navigate to the PTC.Base.Manager Thing.
b. Under Configuration, find the DefaultGlobalManagerConfiguration configuration table.
c. Click Edit icon. for the row with the managerThingName value that matches the manager of the PTC building block that your building block extends from.
For this example, click Edit icon. for the row with the managerThingName value of PTC.StatusImpl.Manager.
d. In the edit window, set the manageThingName field to the name of the manager Thing for your building block that you created in step 2.e.
e. Click Set to set the new value.
f. Click Save to save the changes to the PTC.Base.Manager Thing.
5. Override the service to implement your custom logic.
a. Navigate to the manager Thing Template for your building block. In this example, navigate to the MyCompany.StatusImpl.Manager_TT Thing Template.
b. Under Services, find the service that you want to customize, and click Override icon. to override the service.
c. In the script editor, make the code changes necessary to implement your custom logic.
d. Click Done to save the changes to the service.
e. Click Save to save the changes to the manager Thing.
Customizing a Service on a UI Building Block
If the service you are overriding is a service for a UI building block, complete the following steps:
1. Create a new building block that extends from the PTC building block, in this example, the PTC.ProductionDashboard building block.
To create your new building block, complete the following steps:
a. Create a new project. Use a unique prefix for your project, such as your company name. The PTC prefix is reserved for entities delivered by PTC. For this example, create a project named MyCompany.ProductionDashboard. For each new Thing Template, Thing, or other entity that you create for this building block, add your new project as the Project value on the General Information page for the entity.
b. Create a new Thing Template in your project that uses PTC.Base.ComponentEntryPoint_TT as its Base Thing Template. For this example, name the new Thing Template MyCompany.ProductionDashboard.EntryPoint_TT.
c. Create a new Thing in your project that uses the Thing Template created in step 1.b as its Base Thing Template.
d. Create a new Thing Template in your project that uses the manager Thing Template from the PTC building block that you are extending from as its Base Thing Template. For this example, name the new Thing Template MyCompany.ProductionDashboard.Manager_TT and use PTC.ProductionDashboard.Manager_TT as its Base Thing Template.
e. Create a new Thing in your project that uses the Thing Template created in step 1.d as its Base Thing Template. For this example, name the new Thing MyCompany.ProductionDashboard.Manager and use MyCompany.ProductionDashboard.Manager_TT as its Base Thing Template.
2. Override the service to implement your custom logic.
a. Navigate to the manager Thing Template for your building block. In this example, navigate to the MyCompany.ProductionDashboard.Manager_TT Thing Template.
b. Under Services, find the service that you want to customize, and click Override icon. to override the service.
c. In the script editor, make the code changes necessary to implement your custom logic.
d. Click Done to save the changes to the service.
e. Click Save to save the changes to the manager Thing.
3. Update the manager property on the main mashup for that UI to point to the manager Thing of your new building block. This causes the mashups called from that main mashup to execute services from your new manager rather than the original building block’s manager.
The main mashup is the mashup that is loaded when the menu item for the building block is selected from the DPM navigation menu. The main mashup name can be found in the MenuConfiguration table on the Configuration page of the building block’s manager Thing. It is the menuItemMashupName from the row where the menuName value is MasterMenuNavigation. For example, the main mashup for the Production Dashboard building block is PTC.ProductionDashboard.MainFrame_MU.
a. Navigate to the main mashup for the UI building block.
b. Duplicate the mashup. For example, if you are duplicating the main mashup for the Production Dashboard building block, name it MyCompany.ProductionDashboard.MainFrame_MU. Change the Project value on the General Information page for your mashup to the project that you created in step 1.a.
c. Click Design to view the mashup in the Mashup Builder.
d. In the Explorer, select the top level of the mashup.
e. Under Properties, change the manager property to point to the manager of your new building block that you created in step 1.e.
f. Click Save to save the mashup.
4. Add any configurations from the manager Thing from the original UI building block to the manager Thing for your new building block.
a. Navigate to the manager Thing that you created in step 1.e, in this example MyCompany.ProductionDashboard.Manager.
b. Under Configuration, add the same configurations that are found on the Configuration page for the manager Thing of the original building block, in this example, PTC.ProductionDashboard.Manager. In particular, add the configurations from the MashupConfiguration and DefaultConfiguration tables.
5. Edit the menu item from the DPM navigation menu to launch your duplicate main mashup. For more information, see Customizing the DPM Menu.
6. Ensure that any bookmarks to the original mashup or any services or other mashups which call the original mashup directly are updated to use the duplicate mashup that you created in step 3.b.
Customizing Services from Model Logic Thing Shapes
The PTC model logic Thing Shapes from various building blocks are implemented by Thing Templates in the PTC.MfgModel building block for the equipment model entities (enterprise, region ,site, area, work center, and work unit). You can override services that are inherited from PTC model logic Thing Shapes on individual equipment Things, or override the service on the Thing Template for an equipment model type to change that service for all Things of that equipment model type.
To determine if a service is inherited from a model logic Thing Shape, look at the Services page of the PTC-provided Thing Template for the equipment type where the service is found. The Services page identifies the entities from which services are inherited.
To override a service that is inherited from a model logic Thing Shape and is used on a Thing Template for an equipment type, complete the following steps:
1. Create a new building block that extends from the PTC building block, in this example, the PTC.MfgModel building block.
To create your new building block, complete the following steps:
a. Create a new project. Use a unique prefix for your project, such as your company name. The PTC prefix is reserved for entities delivered by PTC. For this example, create a project named MyCompany.MfgModel. For each new Thing Template, Thing, or other entity that you create for this building block, add your new project as the Project value on the General Information page for the entity.
b. Create a new Thing Template in your project that uses PTC.Base.ComponentEntryPoint_TT as its Base Thing Template. For this example, name the new Thing Template MyCompany.MfgModel.EntryPoint_TT.
c. Create a new Thing in your project that uses the Thing Template created in step 1.b as its Base Thing Template.
* 
If you are also customizing services found on the manager Thing for a PTC building block, follow the instructions for customizing those services found in the previous sections, including creating the manager Thing Template and manager Thing for your new building block.
2. Create a duplicate of the Thing Template for which you want to override the service.
a. Navigate to the original equipment model Thing Template, in this example, PTC.MfgModelDefaultWorkunit_TT.
b. Duplicate the Thing Template. For this example, name the duplicate Thing Template MyCompany.MfgModelDefaultWorkunit_TT. Change the Project value on the General Information page for your mashup to the project that you created in step 1.a.
c. Click Save to save your duplicate Thing Template.
3. Override the service to implement your custom logic.
* 
Override services only on your duplicate Thing Template. Do not override or add services on the Thing Templates in the PTC.MfgModel building block.
a. On the duplicate Thing Template created in step 2.c, under Services, find the service that you want to customize, and click Override icon. to override the service. If the icon is not present for that service, then the service cannot be overridden.
b. In the script editor, make the code changes necessary to implement your custom logic.
c. Click Done to save the changes to the service.
d. Click Save to save the changes to the Thing Template.
4. Update the model type configuration to use your new Thing Template.
a. Navigate to the PTC.MfgModel.Manager Thing.
b. Under Configuration, in the ModelTypeConfiguration configuration table, find the row for the equipment model type whose Thing Template you duplicated in step 3, and click Edit icon. to edit the row.
c. Change the thingTemplate value to the duplicate Thing Template you created in step 3, in this example MyCompany.MfgModelDefaultWorkunit_TT.
d. Click Save to save the changes to the manager Thing.
* 
The preceding procedure changes the Thing Template used for Things of a particular equipment model type. For the changes to have effect, any existing equipment Things of that model type must either be recreated using the new model type Thing Template, or the service must also be customized on the individual equipment Things.
PTC recommends that code changes such as this be made at the Thing Template level rather than on individual Things.
To override a service that is inherited from a model logic Thing Shape for an individual equipment Thing, complete the following steps:
1. Navigate to the equipment Thing.
2. Under Services, find the service that you want to customize, and click Override icon. to override the service.
3. In the script editor, make the code changes necessary to implement your custom logic.
4. Click Done to save the changes to the service.
5. Click Save to save the changes to the equipment Thing.
Was this helpful?