保存错误:字段表达式的初始项必须是具体的 SObject:LIST
我正在编写更新触发器,但收到此错误
保存错误:字段表达式的初始术语必须是具体的 SObject:LIST。
我不确定是什么原因造成的。这是我的代码
trigger Update_Discount_on_QuoteLineItem on Quote (after update) {
List <QuoteLineItem> QLI = new List <QuoteLineItem>();
Map<id,double> MapSoftwareDiscount= new Map <id,double>();
Map<id,double> MapHardwareDiscount= new Map <id,double>();
Set <id> Qid= new Set<id>();
for (Quote Q: Trigger.new)
{
if (Q.Software_Discount__c!=System.Trigger.oldMap.get(Q.Id).Software_Discount__c ||Q.hardware_Discount__c!=System.Trigger.oldMap.get(Q.Id).hardware_Discount__c )
{
Qid.add(Q.id);
MapSoftwareDiscount.put(Q.id,Q.Software_Discount__c);
MapHardwareDiscount.put(Q.id,Q.hardware_Discount__c);
}
}
QLI=[select id,QuoteId,product_category__c,Discount from QuoteLineItem where QuoteId in :Qid];
for(integer i=0; i <QLI.size();i++)
{
if (QLI[i].product_category__c=='Software')
{
QLI[i].Discount=MapSoftwareDiscount.get(QLI.QuoteId); //**ERRORS OUT HERE**
}
else if(QLI[i].product_category__c=='Hardware')
{
QLI[i].Discount=MapHardwareDiscount.get(QLI.QuoteId);
}
}
update QLI;
}
I am writing a trigger on update but i get this error
Save error: Initial term of field expression must be a concrete SObject: LIST.
I am not sure what is causing this. Here is my code
trigger Update_Discount_on_QuoteLineItem on Quote (after update) {
List <QuoteLineItem> QLI = new List <QuoteLineItem>();
Map<id,double> MapSoftwareDiscount= new Map <id,double>();
Map<id,double> MapHardwareDiscount= new Map <id,double>();
Set <id> Qid= new Set<id>();
for (Quote Q: Trigger.new)
{
if (Q.Software_Discount__c!=System.Trigger.oldMap.get(Q.Id).Software_Discount__c ||Q.hardware_Discount__c!=System.Trigger.oldMap.get(Q.Id).hardware_Discount__c )
{
Qid.add(Q.id);
MapSoftwareDiscount.put(Q.id,Q.Software_Discount__c);
MapHardwareDiscount.put(Q.id,Q.hardware_Discount__c);
}
}
QLI=[select id,QuoteId,product_category__c,Discount from QuoteLineItem where QuoteId in :Qid];
for(integer i=0; i <QLI.size();i++)
{
if (QLI[i].product_category__c=='Software')
{
QLI[i].Discount=MapSoftwareDiscount.get(QLI.QuoteId); //**ERRORS OUT HERE**
}
else if(QLI[i].product_category__c=='Hardware')
{
QLI[i].Discount=MapHardwareDiscount.get(QLI.QuoteId);
}
}
update QLI;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我明白问题出在哪里了。我应该一直使用
我没有在
get(QLI[i].QuoteId)
中包含[i]
。I figured out what the issue was. I should have been using
I didn't include the
[i]
in theget(QLI[i].QuoteId)
.