Loading
Feature degradation | Gmail Email delivery failureRead More
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
          Show Promotions Based on Transaction Currency in Multicurrency Orgs (Beta)

          Show Promotions Based on Transaction Currency in Multicurrency Orgs (Beta)

          Complete this optional setup to show promotions based on the transaction’s currency. By default, when you use multiple currencies in your org, the Browse Catalogs window shows promotions based on the currency of the account associated with the transaction.

          Required Editions

          Available in: Lightning Experience
          Available in: Enterprise, Unlimited, and Developer Editions of Agentforce Revenue Management with the Revenue Cloud Advanced license, and the Global Promotions Management Basic Add-On license or Loyalty Management - Growth or Advanced license.
          User Permissions Needed
          To customize context definitions: Context Service Admin
          To customize flows: Manage Flows
          Important
          Important

          You can show promotions based on the transaction currency only if you haven’t set up channel-based promotions.

          Configure the Product Discovery Context Definition

          Change the definition to show promotions based on the transaction currency.

          1. Edit your extended Product Discovery context definition.
            1. From Setup, find and select Context Definitions.
            2. Click Custom Definitions.
            3. Click your extended Product Discovery context definition.
              If you’re using the prebuilt context definition, extend your ProductDiscoveryContext context definition.
            4. Click Edit.
          2. On the Edit Context Definitions page, click Next.
          3. On the Edit Structure page, click Add Sibling Node next to Promotion__std.
          4. For name, enter Transaction__c, and click Next.
          5. Click Transaction__c.
          6. Click Add Attributes and add the currency details.
            1. For name, enter ccycode__c.
            2. For Type, select INPUT OUTPUT
            3. For Data Type, select STRING.
          7. Click Add Attributes and add the account details.
            1. For name, enter accountId__c.
            2. For Type, select INPUT OUTPUT.
            3. For Data Type, select STRING.
          8. Click Add Attributes and add the ID details.
            1. For name, enter id__c.
            2. For Type, select INPUT OUTPUT.
            3. For Data Type, select STRING.
          9. Click Next.
          10. On the Edit Attribute Tags page, add the attribute names as tag names.
            1. Next to accountId__c, click Add Tags.
            2. For tag name, enter accountId__c.
            3. Click Done.
            4. Repeat these steps to add tags for ccycode__c and id__c.
              Use the attribute name as the tag name.
            5. Save your changes.

          Create a Custom Promotions Mapping

          1. Open the Map Data tab.
          2. Next to ProductDiscoveryPromoMapping, click Context Definitions and select Clone.
          3. Enter a name, and save your changes.
          4. Delete the mapping between the Account node and the SalesTransaction node.
          5. Map these nodes and attributes.
            Product Discovery Context Sales Transaction Context
            Transaction__c SalesTransaction
            ccycode__c CurrencyIsoCode
            accountId__c Account
          6. Save your changes.
          7. Next to ProductDiscoveryMapping, click Context Definitions and select Edit Input Mapping.
          8. Click Generate Node Mappings.
          9. In the Generate node mappings window, click Retain and Generate.
          10. Save your changes.
          11. Activate your context definition.

          Create an Apex Class

          Create an Apex class for a flow action.

          1. Click Setup and select Developer Console.
          2. Select File | New | Apex Class.
          3. For name, enter DiscoverProductFlowAction.
          4. Add this code, and save your changes.
            public class DiscoverProductFlowAction {
                
                // Define input parameters
                public class FlowInput {
                    @InvocableVariable(required=false)
                    public String objectApiName;
                    
                    @InvocableVariable(required=false)
                    public String recordId;
                }
                
                // Define output parameters     
                public class FlowOutput {
                    @InvocableVariable
                    public runtime_industries_cpq.ContextDataInput[] additionalContextData;
                }
            
                // This method is invoked from a flow
                @InvocableMethod(label='Process Input' description='Creates the Array of ContextDataInput for additional Context Data')
                public static List<FlowOutput> generateAdditionalContextData(List<FlowInput> inputs) {
                    String objectApiName;
                    String recordId;
                    String ccyCode;
                    String accountId;
                    Quote quoteObject;
                    Order orderObject;
                    FlowOutput output = new FlowOutput();
                    
                    // Capture input from the flow
            		for(FlowInput input : inputs ){
                        objectApiName = input.objectApiName;
                        recordId = input.recordId;
                    }
                    
                    //Write logic to Query Currency from Transaction Entity
                    if(objectApiName == 'Quote') {
                        quoteObject = [SELECT CurrencyIsoCode,AccountId FROM Quote WHERE Id = :recordId LIMIT 1][0];
                        ccyCode = quoteObject.CurrencyIsoCode;
                        accountId =  quoteObject.AccountId;       
                    } else if(objectApiName == 'Order') {
                        orderObject = [SELECT CurrencyIsoCode,AccountId FROM Order WHERE Id = :recordId LIMIT 1];
                        ccyCode = orderObject.CurrencyIsoCode;
                        accountId =  orderObject.AccountId;   
                    }
            
                    //Populate the ContextDataInput list to store additional context data
                  	List<runtime_industries_cpq.ContextDataInput> listContextData = new List<runtime_industries_cpq.ContextDataInput>();
                    runtime_industries_cpq.ContextDataInput cd1 = new runtime_industries_cpq.ContextDataInput();
                    cd1.nodeName = 'Transaction'; //Where Quote is the name of the node in the context definition.
                    cd1.nodeData = new Map<String,Object>();
                    cd1.nodeData.put('id',recordId);  
                    cd1.nodeData.put('ccycode',ccyCode); 
                    cd1.nodeData.put('accountId',accountId); 
                    listContextData.add(cd1);
                    
                    // Return the additional Context Data to a flow
                    output.additionalContextData = listContextData;
                    return new List<FlowOutput>{output};       
                }
            }
            

          Customize the Product Discovery Flow

          1. In Setup, find and select Flows.
          2. Open your Product Discovery flow.
            If you’re using the default flow, open Discover Products.
          3. Before the Product list screen element, click Add Element and select Action.
          4. Enter a label and API name.
          5. Find and select DiscoverProductFlowAction.
          6. Turn on objectAPIName, and enter objectAPIName as its value.
          7. Turn on recordId, and enter recordId as its value.
          8. Save your changes.
          9. Click Product list.
          10. Click Product List Page Container.
          11. For the Context Data Input Array attribute, select the output of the action.
          12. Save your changes.
          13. Activate the flow.
           
          Loading
          Salesforce Help | Article