保存错误:字段表达式的初始项必须是具体的 SObject:LIST

发布于 2024-12-16 02:46:08 字数 1227 浏览 0 评论 0原文

我正在编写更新触发器,但收到此错误

保存错误:字段表达式的初始术语必须是具体的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

还在原地等你 2024-12-23 02:46:08

我明白问题出在哪里了。我应该一直使用

  QLI[i].Discount=MapSoftwareDiscount.get(QLI[i].QuoteId); 

我没有在 get(QLI[i].QuoteId) 中包含 [i]

I figured out what the issue was. I should have been using

  QLI[i].Discount=MapSoftwareDiscount.get(QLI[i].QuoteId); 

I didn't include the [i] in the get(QLI[i].QuoteId).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文