Loading
Get Started with Communications, Media, and Energy & Utilities (CME)...
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Implement Location-Based Pricing

          Implement Location-Based Pricing

          Implement attribute-based pricing that evaluates a range of numeric values in an attribute or a field. Using this approach, you can override pricing for a product when, for example, the Quantity field on the line item exceeds a certain threshold or the numeric value of an attribute falls within a certain range.

          1. In Setup, find and select Custom Settings.
          2. Click the Custom Class Implementation custom setting.
          3. Click Manage and then click New.
          4. Enter the Name as CpqNgpCtxHydrationInterfaceHook. This is the Hook name.
          5. Enter the Class Name as CpqNgpCtxHydrationInterfaceImpl
            Here’s a sample custom class​.
            
            Sample Class :: Passing AccountShippingCountry to Order context.
            
            global class CpqNgpCtxHydrationInterfaceImpl implements System.Callable, devopsimpkg19.VlocityOpenInterface {
            
                global CpqNgpCtxHydrationInterfaceImpl()
                {
            
                }
            
                public Object call(String action, Map<String, Object> args) 
                {
                    Map<String,Object> inputMap = (Map<String,Object>)args.get('input');
                    Map<String,Object> outputMap = (Map<String,Object>)args.get('output');
                    Map<String,Object> options = (Map<String,Object>)args.get('options');
                    
                    return invokeMethod(action, inputMap, outputMap, options);
                }
            
                public Boolean invokeMethod(String methodName,
                                                Map<String,Object> inputs,
                                                Map<String,Object> output,
                                                Map<String,Object> options)
                {
                    System.debug('inside cpq hook interface');
                    System.debug('methodName ::: ' + methodName);
                    System.debug('inputs ::: ' + JSON.serialize(output));
                            
                    if( methodName.equalsIgnoreCase('hydratePricingContext.PostInvoke'))
                    {
                        System.debug('inside post hook interface');
                        Map<String, Object> result = (Map<String, Object>)output.get('pricingInputMap');
                        System.debug('result :: ' + result);
                        if(result != null)
                        {
                            List<Object> orders = (List<Object>)result.get('Order');
                            if(orders != null)
                            {
                                for(Object orderObj : orders)
                                {
                                    Map<String, Object> orderMap = (Map<String, Object>) orderObj;
                                    Order order = [SELECT Id, Account.ShippingCountry FROM Order WHERE Id =: (String) orderMap.get('CartId')];
                                    orderMap.put('AccountShippingCountry', order.Account.ShippingCountry);
                                }
                            }
                        }
                    }
                    System.debug('outputs ::: ' + JSON.serialize(output));
                    return true;
                }
            }
            
          6. Add AccountShippingCountry to the extended or cloned Context Definition from the Standard Context Definition and update the context mapping. You can either create a new context mapping by deleting the existing mapping, or alternatively map this new field to one of the Order fields in the existing context mapping.
            Implement Location Based Pricing
          7. From the App Launcher, find and select LookupTables.
            1. Click New.
            2. .From Lookup Table Type, select Decision Table.
            3. Click Next.
          8. Specify the decision table details.
            1. Name: LocationBasedDM
            2. Type: Standard
          9. Create a decision matrix version.
            1. From the App Launcher, find and select LookupTables.
            2. Click the link of the CMEAttributeBasedPricingDM decision matrix for which you're creating another version.
            3. On the record page of the matrix, on the Related tab, click New.
            4. Enter a name and a version number for your new decision matrix version.
              For more information on how to create a decision matrix version, see Create a Version of a Standard Decision Matrix.
            5. Activate the decision matrix version.
          10. Add the decision matrix to the active pricing recipe.
            1. In Setup, find and select Pricing Recipes.
            2. Choose the recipe that you want to add to your lookup tables.
            3. On the Price Adjustment Matrix tab, click Modify.
            4. Select the LocationBasedDM lookup table.
            5. Select Price Component Type as Custom Discount.
          11. Add the Price Adjustment Matrix pricing element.
            After the Price List element and before the Aggregate element, add a pricing element of type Price Adjustment Matrix. For more information on Price Adjustment Matrix, see Price Adjustment Matrix.
            1. Click Add elements icon, and select the Price Adjustment Matrix element from the list.
            2. In the Lookup Table Details field, search for and select your Custom Price Adjustment Matrix.
            3. Map all your variables with the context tags.
              Implement Location-Based Pricing
          12. Save and activate the pricing procedure.
           
          Loading
          Salesforce Help | Article