我们已经建立了这个流程来帮助优先考虑我们的案例。要做到这一点,我希望通过电子邮件到个案触发新案例记录。然后查询它是否与帐户相关。如果是,我想返回一个值,cScore。然后插入。如何在案例记录成为案例时访问案例记录。 (Email2Case)
这是我迄今为止,它返回这个错误:
Error: Invalid Data. Review all error messages below to correct your data. Apex trigger newCaseScoring caused an unexpected exception, contact your administrator: newCaseScoring: execution of BeforeInsert caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.newCaseScoring: line 12, column 18
这里是我的代码:
触发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;
}
}
}
}
}
感谢您的帮助。
谢谢你的经历。我更新了我的代码。这不是一个工作模式,我只是想把它扔到那里,以确保我抓住了这个愿景。我做得对吗? – Havoc783
我不认为你需要查询案件。 'for(case cases:cList){'can become'for(Case cases:Trigger.new){'。如果你要为你的账户建立一个Map,你不需要做循环内循环。尝试'地图 aMap =新地图([Select Id,Customer_s_Score_Total__c from Account where IN:idList]);' –
好吧,谢谢,我会试试。谢谢你的帮助! – Havoc783