我正在编写一个代码,其中我想使用流程生成器来更新记录中的文本框。这是功能。
这是我的代码。
@InvocableMethod(label='Get Prediction')
public static void UpdateEngagement(List<getInputDetails> getIDetails){
String s = JSON.serialize(getIDetails);
AI_EngagementSentiment_PB.service(s);
}
@future(callout=true)
public static void service(String s){
einsteinplay.Einstein_PredictionService service = new einsteinplay.Einstein_PredictionService(einsteinplay.Einstein_PredictionService.Types.SENTIMENT);
System.debug(s);
List<getInputDetails> details = (List<getInputDetails>)JSON.deserialize(s, List<getInputDetails>.class);
System.debug('details.textToPredict');
System.debug(details[0].textToPredict);
einsteinplay.Einstein_PredictionResult prediction = service.predictSentiment('CommunitySentiment', details[0].textToPredict, 3, null);
System.debug(prediction);
System.debug('in If');
Engagement__c EngagementUpdate;
EngagementUpdate = [select Positive_Sentiment__c, Negative_Sentiment__c, Neutral_Sentiment__c from Engagement__c where id = : details[0].caseID];
EngagementUpdate.Neutral_Sentiment__c = prediction.probabilities[0].probability;
EngagementUpdate.Positive_Sentiment__c = prediction.probabilities[1].probability;
EngagementUpdate.Negative_Sentiment__c = prediction.probabilities[2].probability;
Update EngagementUpdate;
}
运行此命令时,我得到的结果(全部Sys.debug
个)一直到in if
,但是此后抛出以下错误。
02:12:24:218 FATAL_ERROR System.DmlException: Update failed. First exception on row 0 with id a0W4K000000kc6vUAA; first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “AI Engagement Sentiment” process failed. Give your Salesforce admin these details. An Apex error occurred: System.AsyncException: Future method cannot be called from a future or batch method: AI_EngagementSentiment_PB.service(String)
请让我知道我要去哪里哪里以及如何解决这个问题。
以下是字段
谢谢。