You need to sign in to do that
Don't have an account?
Shruthi 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;
}
}
}
{
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;
}
}
}
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.
{
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;
}
}
}