Newer Version Available
TPM UI Edit Access Rights Customization Hook
Edit Access Rights is a mechanism used by the TPM UI application to selectively
enable or disable certain functionalities or UI elements depending on the business
logic.
The core solution generates the list of Edit Access Rights based on business logic. However, there might be scenarios where you can apply your own logic to:
- Enable or disable Promotion and Tactic global Editability and Visibility based on your custom logic.
- Enable or disable functionalities of the included Lightning components to suit your needs.
Configuration
Edit Access Rights are handled on different calls for Promotion and Tactic Level access
rights. To customize the Promotion Edit Access Rights, introduce a callable APEX class as a
customization hook. To configure the hook, go to Setup → Custom Metadata Types →
CGCloud Process Customization, and add the following record:
- Label: TPM_Promotion_EARightsAccess_Promotion
- DeveloperName: TPM_Promotion_EARightsAccess_Promotion
- Class: <Your Callable APEX Class>
- Enabled: checked
- Method: EARights
- APEX class structure
1global class <Your Callable APEX Class> implements System.Callable {
2
3 global Object call(String action, Map<String, Object> args) {
4 // Read Transaction Id
5 String txId = (String) args.get('txId');
6 // Get the Promotion Id
7 Id promotionId = args.get('promotionId');
8 // Get the EARigths
9 List<cgcloud.EARightsAccess> promotionRights = (List<cgcloud.EARightsAccess>) args.get('EARights');
10
11 // Your custom logic goes here
12 }
13}To customize the Tactic Edit Access Rights, introduce another APEX class as a customization
hook. To configure the hook, go to Setup → Custom Metadata Types → CGCloud
Process Customization, and add the following record:
- Label: TPM_Promotion_EARightsAccess_Tactic
- DeveloperName: TPM_Promotion_EARightsAccess_Tactic
- Class: <Your Callable APEX Class>
- Enabled: checked
- Method: EARights
- APEX class structure
1global class <Your Callable APEX Class> implements System.Callable {
2
3 global Object call(String action, Map<String, Object> args) {
4 // Read Transaction Id
5 String txId = (String) args.get('txId');
6 // Get the Promotion Id
7 Id promotionId = args.get('promotionId');
8 // Get the EARigths
9 List<cgcloud.EARightsAccess> tacticRights = (List<cgcloud.EARightsAccess>) args.get('EARights');
10
11 // Your custom logic goes here
12 }
13}EARightsAccess Class
The EARightsAccess class allows you to access the Edit Access Rights the application uses. You can’t add new instances to the list. However, you can change the Edit Access Rights of the existing elements to suit your needs.
Each EARightsAccess instance provides the following properties:
- Name: String (Provides the name of the Right).
- Type: String (Category of the Right).
- Visible: Boolean (If the referenced item is visible).
- Editable: Boolean (If the referenced item is editable).
Promotion Edit Access Rights
The following table describes all the Promotion Level Edit Access Rights that you can
modify in your customization hook:
| Name | Type | Visible | Editable | Description |
|---|---|---|---|---|
| cgcloud__Promotion__c | Object | True if SObject is visible, false otherwise | True if SObject is editable, false otherwise | Controls global access to the promotion. All the fields in Promotion cards are editable. |
| PROMOTION_PLANNING_GRID_BUTTON | UI element | If Promotion template calculation mode is 'Adhoc' or 'Writeback' | Same as Visible | Controls visibility of the display PL button. |
| PROMOTION_EDIT_BUTTON | UI element | If User has Edit Access on Promotion | If User has Edit access, it's not a pushable promotion with a push in progress, is not a child promotion and the promotion is not frozen. | Controls visibility of the edit mode button. |
| ADD_TACTIC_BUTTON | UI element | If Promotion Template has related Tactic Templates | TRUE | Controls visibility of the Add Tactic button on the header. |
| TACTIC_DUPLICATE_BUTTON | UI element | TRUE | TRUE | Controls visibility of the duplicate tactic on header and the tactic navigation components. |
| PROMOTION_PLANNING_BUTTON | UI element | TRUE | TRUE | Controls visibility of the display promotion planning page area. |
| PROMOTION_ATTACHMENT_BUTTON | UI element | TRUE | TRUE | Controls visibility of the display promotion attachments on the header. |
| TACTIC_DELETE_BUTTON | UI element | TRUE | TRUE | Controls visibility of the duplicate tactic and the tactic navigation components. |
| ROI_KPI_CHART | UI element | If the Promotion Template Calculation mode is 'Writeback' | Same as Visible | Controls visibility of the ROI promotion chart. |
| COSTS_KPI_CHART | UI element | If the Promotion Template Calculation mode is 'Writeback' | Same as Visible | Controls visibility of the costs promotion chart. |
| SUBACCOUNT_GRID | UI element | If Promotion Template has Sub Accounts Enabled | Same as Visible | Controls visibility of the sub accounts card. |
| VOLUME_PLANNING_GRID | UI element | If Promotion Template has Display VPC | Same as Visible | Controls visibility of the VPC card. |
| SCENARIO_PLANNING_BUTTON | UI element | If Promotion Template has Enable Scenario Planning and the Promotion Phase is not int the Promotion Cleaning Phases of the Template. | Same as Visible | Controls visibility of the scenario planning menu. |
| PARTICIPATION_CUSTOMER_GRID | UI element | If Promotion Template has Is Pushable | Same as Visible | Controls visibility of the participating customers card for pushable promotions. |
| cg_cloud__Anchor_Account__c | Attribute | True if Anchor Type is Customer and user has view access to the field | True if Anchor Type is Customer and user has edit access to the field | Controls view and edit access for the anchor customer field. |
| cg_cloud__Anchor_Account_Set__c | Attribute | True if Anchor Type is Customer Set and user has view access to the field | True if Anchor Type is Customer Set and user has edit access to the field | Controls view and edit access for the anchor customer set field |
| cg_cloud__Slogan__c | Attribute | True if user has view access to the field | True if user has edit access to the Slogan_Language_1__c field | Controls view and edit access for the slogan field. |
| cg_cloud__Date_From__c | Attribute | True if user has view access to the field | True if user has edit access to the field and Promotion Template Timeframe Determination Policy is not Simple | Controls view and edit access for the date from field. |
| cg_cloud__Date_Thru__c | Attribute | True if user has view access to the field | True if user has edit access to the field and Promotion Template Timeframe Determination Policy is not Simple | Controls view and edit access for the date thru field. |
| cg_cloud__Commit_Date__c | Attribute | True if user has view access to the field | True if user has edit access to the field and Promotion Template Timeframe Determination Policy is not Simple | Controls view and edit access for the commit date field. |
| All other Promotion SObject fields | Attribute | True if user has view access to the field | True if user has edit access to the field | Controls view and edit access for the user to all other promotion fields based on FLS. |
Tactic Edit Access Rights
The following table describes all the tactic level edit access rights that you can modify
in your customization hook:
| Name | Type | Visible | Editable | Description |
|---|---|---|---|---|
| cgcloud__Tactic__c | Object | True if SObject is visible, false otherwise | True if SObject is editable, false otherwise | Controls global access to the tactic. |
| TACTIC_FUNDS_CARD | UI element | If Promotion Template has Display Fund Card | Same as Visible | Controls visibility of the fund Card on tactic. |
| ROI_KPI_CHART | UI element | If the Promotion Template Calculation mode is 'Writeback' | Same as Visible | Controls visibility of the ROI tactic chart. |
| COSTS_KPI_CHART | UI element | If the Promotion Template Calculation mode is 'Writeback' | Same as Visible | Controls visibility of the costs tactic chart. |
| SPEND_PLANNING_CARD | UI element | If Promotion Template has Display SPC | Same as Visible | Controls visibility of the SPC card on tactic. |
| All other Tactic SObject fields | Attribute | True if user has view access to the field | True if user has edit access to the field | Controls view and edit access for other tactic fields based on FLS. |
- Example
1global class MyEditAccessRightsHook implements System.Callable {
2
3 global Object call(String action, Map<String, Object> args) {
4 // Read Transaction Id
5 String txId = (String) args.get('txId');
6 // Get the Promotion Id
7 Id promotionId = args.get('promotionId');
8 // Get the EARigths
9 List<cgcloud.EARightsAccess> promotionRights = (List<cgcloud.EARightsAccess>) args.get('EARights');
10
11 // Get the Promotion Template name
12 List<cgcloud__Promotion__c> promos = [
13 SELECT cgcloud__Promotion_Template__r.Name
14 FROM cgcloud__Promotion__c
15 WHERE Id = :promotionId
16 LIMIT 1
17 ];
18
19 // Check if its the target template
20 Boolean isNoTactics = promos[0].cgcloud__Promotion_Template__r.Name == 'No Tactics';
21
22 // Search the related EARightsAccess instance
23 for (cgcloud.EARightsAccess acl : promotionRights) {
24 if (acl.Name == 'PROMOTION_EDIT_BUTTON' && isNoTactics) {
25 acl.Visible = false;
26 acl.Editable = false;
27 }
28 }
29
30 }
31}