Newer Version Available

This content describes an older version of this product. View Latest

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.
  1. Log in to your Salesforce org, and go to Developer Console.
  2. Create a global Apex class that implements the System.Callable interface.
  3. 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
    3  global Object call(String action, Map<String, Object> params) {
    4    // Get the proposed products 
    5    List<Product2> products = (List<Product2>) params.get('products');
    6    
    7    // Custom code
    8    return products;
    9  }
    10}
  4. 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    // Get the proposed products
    7    List<Product2> products = (List<Product2>) params.get('products');
    8
    9    // Get product IDs from the custom Proposed_Products__c object
    10    List<Proposed_Products__c> proposedProducts = [
    11      SELECT ProductId__c
    12      FROM Proposed_Products__c
    13    ];
    14    List<Id> productIdList = new List<Id>();
    15
    16    for (Proposed_Products__c proposedProduct : proposedProducts) {
    17      productIdList.add(proposedProduct.ProductId__c);
    18    }
    19
    20    // Include all products belonging to the 'Beverages' category.
    21    for (Product2 product : products) {
    22      if (product.Category__c == 'Beverages') {
    23        productIdList.add(product.Id);
    24      }
    25    }
    26
    27    return JSON.serialize(productIdList);
    28  }
    29}
  5. From Setup, in the Quick Find box, enter Custom Metadata Types, and then expand Custom Metadata Types.
  6. Click Manage Records on the CGCloud Process Customization row.
  7. 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

    Before invoking the customization hook, ensure that the Consider Listing setting in Order Template is set to Yes.

    Note

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.