您位於此處:
特定商店的建議造訪
使用 Apex 選取您要 Einstein 提供造訪建議的商店清單。建立 Apex 動作後,使用您策略中的「產生」元素以選取 Apex 動作。
必要版本
| 可用版本:啟用 Consumer Goods Cloud 的 Professional、Enterprise 和 Unlimited 版本。 |
備註 我們建議您使用「產生」元素以載入資料。使用「產生」元素有助於克服由 Salesforce 管理員施加的個別交易限制。
重要 若要在策略中使用 Apex 動作,請您的開發人員以 @InvocableMethod 註解適當的方法。
用於篩選商店的 Apex 類別如下所示:
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;
}
}
當您在策略中指定 Apex 動作後,請將可叫用變數標籤指定為 Apex 動作的參數。在您策略中的「對應」元素,將參數與您想要造訪建議的商店識別碼對應。商店識別碼必須在逗號分隔清單中以雙引號指定。
此文章是否解決您的問題?
請讓我們知道,以便我們改進!

