Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Customize the Retail Order Proposal List Creation Process
To customize the order proposal list creation process, create a callable Apex class as
a customization hook.
- Log in to your Salesforce org, and go to Developer Console.
- Create a global Apex class that implements the System.Callable interface.
-
Override the global call method that has these
parameters.
- action: String. The behavior for the method to exhibit.
- params: Map<String,Object>. Arguments to be used by the specified action.
Here’s the Apex class structure.
1global class <Your Callable APEX Class> implements System.Callable { 2 global Object call(String action, Map<String, Object> params) { 3 // Retrieve the list of proposed products from the parameters 4 List<Product2> products = (List<Product2>) params.get('products'); 5 6 // Retrieve the account ID and order ID from the parameters 7 Id accountId = (Id) params.get('accountId'); 8 Id orderId = (Id) params.get('orderId'); 9 10 // Initialize a list to store product IDs 11 List<Id> productIdList = new List<Id>(); 12 13 // Custom code to add or remove products 14 // Add or remove product IDs to/from productIdList as needed 15 16 // Return the productIdList in JSON string format 17 return JSON.serialize(productIdList); 18 } 19} -
Modify the list of products displayed on the order proposal list UI based on your
custom logic.
Here’s a sample Apex code that adds additional product IDs from a custom object, Proposed_Products__c, and the IDs that belong to the beverages product category to the list of proposed products.
1global class OrderProposalListCustomization implements System.Callable { 2 public class CustomizationException extends Exception { 3 } 4 5 public Object call(String m, Map<String, Object> params) { 6 List<Product2> products = (List<Product2>) params.get('products'); 7 Id accountId = (Id) params.get('accountId'); 8 Id orderId = (Id) params.get('orderId'); 9 List<Id> productIdList = new List<Id>(); 10 Integer productListSize = 4; 11 12 // Get the account name 13 List<Account> accountList = [ 14 SELECT Id, Name 15 FROM Account 16 WHERE Id = :accountId 17 LIMIT 1 18 ]; 19 20 if (!accountList.isEmpty()) { 21 Account account = accountList[0]; 22 23 // If the account name contains 'NTO', display a higher number of products. 24 if (account.Name.contains('NTO')) { 25 productListSize = 12; 26 } 27 } 28 29 for (Integer i = 0; i < productListSize; i++) { 30 productIdList.add(products.get(i).Id); 31 } 32 33 return JSON.serialize(productIdList); 34 } 35} - From Setup, in the Quick Find box, enter Custom Metadata Types, and then expand Custom Metadata Types.
- Click Manage Records on the CGCloud Process Customization row.
-
Click New, fill in these details, and then save your work.
- Label: RE_Order_Proposal_List
- DeveloperName: RE_Order_Proposal_List
- Class: <Your Callable APEX Class>
- Method: proposalList
- Enabled: Select the checkbox
Your Apex customization hook is enabled. When an order proposal list is created, the
call method modifies the proposed product list based on
your custom logic.