我们已经设置了此流程来帮助确定案例的优先级.为此,我希望在通过电子邮件发送到案例后触发新的案例记录.然后查询它是否与帐户相关.如果是,我想返回一个值cScore.然后插入.
这是我到目前为止,它返回此错误:
错误:无效数据.查看下面的所有错误消息以更正您的数据.Apex触发newCaseScoring导致意外异常,请联系您的管理员:newCaseScoring:由以下原因导致的BeforeInsert执行:System.QueryException:List没有用于赋值给SObject的行:Trigger.newCaseScoring:第12行,第18列
这是我的代码:
在Case上插入newCaseTrigger(插入之前){
if(Trigger.isInsert){
List<Case> cList = [Select AccountId, Id, Priority_Score__c, Case_Priority_Score__c FROM Case WHERE Id IN :Trigger.new];
List<Case> updateList = [Select AccountId, Id, Priority_Score__c, Case_Priority_Score__c FROM Case WHERE Id IN :Trigger.new];
System.debug('This is the cList:' + cList);
integer size;
integer cnt=0;
List<id> idList = New List<id>();
for(Case cases : cList){
idList.add(cases.AccountId);
size = idList.size();
System.debug('This is the idList:' + idList);
System.debug('This is the size:' + size);
cnt++;
System.debug(cnt);
}
List<Account> aList = [Select Id, Customer_s_Score_Total__c from Account where id =:idList];
integer num;
for(Id a : aList){
for(Id b : idList){
if(aList.Id == idList){
num = aList.Customer_s_Score_Total__c;
updateList.Priority_Score__c = num;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
}
谢谢您的帮助.
第12行中的查询返回0条记录,因为Case还没有Id.由于您处于before insert触发状态,因此尚未提交案例.
我想你要做的是:
List<Id>Case.AccountId值.List<Id>上一步中的帐户查询帐户.你会不会需要做插入的呼叫.您对案例记录所做的任何更改都将自动保存,因为您处于before insert触发器中.
| 归档时间: |
|
| 查看次数: |
490 次 |
| 最近记录: |