Loading
Feature degradation | Gmail Email delivery failureRead More
Set Up and Maintain Retail Execution
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
          Recommend Visits for Specific Stores

          Recommend Visits for Specific Stores

          Use Apex to select a list of stores that you want Einstein to provide visit recommendations for. After you create an Apex action, use the Generate element in your strategy to select the Apex action.

          Required Editions

          Available in: Professional, Enterprise, and Unlimited editions where Consumer Goods Cloud is enabled.
          Note
          Note We recommend that you use the Generate element to load the data. Using the Generate element helps overcome the per transaction limits imposed by the Salesforce governor.
          Important
          Important To use an Apex action in a strategy, ask your developer to annotate the appropriate method with @InvocableMethod.

          Here's what an Apex class for filtering stores looks like:

          global class LoadStores {
              global class RecommendationRequest {
                  @InvocableVariable(label='Store Ids')
                  public String siteIds;
              }
              
              @InvocableMethod(label='Get Stores from Request' description='Gets stores that are chosen in the request')
              public static List<List<Recommendation>> getVisits(List<RecommendationRequest> requests) {
                  List<List<Recommendation>> recos = new List<List<Recommendation>>();
                  for(RecommendationRequest request : requests){
                      List<Recommendation> output = new List<Recommendation>();
                      List<String> siteList = request.siteIds.split(',');
                      List<RetailStore> stores = [SELECT Id, Name FROM RetailStore WHERE Id IN :siteList];
                      for(RetailStore store : stores){
                          Recommendation rec = new Recommendation(
                              Name = store.Name,
                              Description = store.Name,
                              ExternalId = store.Id
                          );
                          output.add(rec);
                      }
                      recos.add(output);
                  }
                  return recos;
              }
          }

          After you specify the Apex action in the strategy, specify the invocable variable label as the parameter for the Apex action. In the Map element of your strategy, map the parameter with the Id of the stores you want visit recommendations for. The store IDs must be specified inside double quotes in a comma-separated list.

           
          Loading
          Salesforce Help | Article