function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shruthi NarsiShruthi Narsi 

Trigger Add production on OpP

rigger QuoteLineItemTrigger on Quotes__c (Before insert, Before update)
{
List<QuoteLineitem__c> quote = new List<QuoteLineitem__c>();
Set<Id>productidSet =New Set<Id>();
for(Quotes__c child : trigger.new )
{
if(child.IsSyncing__c != true)
{
//productidSet.add(child.QuoteLineitem__r.Product2Id__c);
//quote.add(child.Product_Image__c = Product2Id.Product_Image__c);
quote.add(child);
}
}

for(QuoteLineitem__c lst:lstQuote){
productidSet.add(lst.Product2Id__c);
}

Map<id,Product2__c>ProductMap=New Map<Id,Product2__c>([Select id,Product2Id__c,Name From Product2__c where id=:productidSet ]);
List<QuoteLineitem__c> lstQuote= [select id from QuoteLineitem__c where QuotesId__c=:quote];


for(QuoteLineitem__c child : lstQuote)
{
if(child.Product2Id__c != null && ProductMap.containskey(child.Product2Id__c))
{
child.Product2Id__c = ProductMap.get(child.Product2Id__c).Name;
}
}
}

User-added image

 
Puneet_MishraPuneet_Mishra
Product2Id__c, __c represents custom field, check if you have any field with Product2Id__c as API name, if not then you have to remove that reference from your SOQL.
What are u trying to achieve by referencing Product2Id__c  and you are making a SOQL on Product2__c, but screenshot error says abt Product2.
If you are trying to access Id then you can access Id by just referencing Id instead of Product2Id__c.
Shruthi NarsiShruthi Narsi
trigger QuoteLineItemTrigger on Quotes__c (Before insert, Before update)
{
List<QuoteLineitem__c> quote = new List<QuoteLineitem__c>();
Set<Id>productidSet =New Set<Id>();
List<Id> quoteId=new List<Id> ();
for(Quotes__c child : trigger.new )
{
if(child.IsSyncing__c != true)
{
//productidSet.add(child.QuoteLineitem__r.Product2Id__c);
//quote.add(child.Product_Image__c = Product2Id.Product_Image__c);
quoteId.add(child.id);
}
}
List<QuoteLineitem__c> quote1= [select id from QuoteLineitem__c where QuotesId__c =:quoteId];
    



for(QuoteLineitem__c lst:quote){
productidSet.add(lst.Product2Id__c);
}

Map<id,Product2__c>ProductMap=New Map<Id,Product2__c>([Select id,Name From Product2__c where id=:productidSet ]);
List<QuoteLineitem__c> lstQuote= [select id from QuoteLineitem__c where id=:quote];


for(QuoteLineitem__c child : lstQuote)
{
if(child.Product2Id__c != null && ProductMap.containskey(child.Product2Id__c))
{
child.Product2Id__c = ProductMap.get(child.Product2Id__c).Name;
}
}
}
Shruthi NarsiShruthi Narsi
now im not getting any errors
Shruthi NarsiShruthi Narsi
but logic is not correct