You need to sign in to do that
Don't have an account?
sfdeveloper12
Error: Compile Error: Initial term of field expression must be a concrete SObject: List<Quote> at line 46 column 10
Hello,
I am writing a code where i am almost done. but i dont know how to get rid of this error. I want to compare accounts on quote object and one of the object which is child object (rate and commision) of product object. When this 2 are same then i want to update field on rate and commision object on quote line item object. can anyone help me with this?
trigger UpdateAgreedRate on QuoteLineItem (before insert, before update) {
system.debug('****************InTrigger**********************');
if(trigger.isBefore && (trigger.isInsert || trigger.isUpdate)){
String QuoteID ;
set<id> PIds = new set<id>();
for (QuoteLineItem childObj : Trigger.new) {
if(QuoteID == null) {
QuoteID = childObj.QuoteID;
}
if(childObj.Product2Id != null){
PIds.add(childObj.Product2Id);
}
}
system.debug('QuoteID 19 -->'+QuoteID );
if(QuoteID != null) {
List<Quote> quotes = [select Id, AccountId, Venue__c from Quote where Id =:QuoteID ];
if(quotes.size() > 0) {
Quote QuoteDetails = quotes[0];
system.debug('QuoteDetails 26 -->'+QuoteDetails );
for (QuoteLineItem item : Trigger.new) {
system.debug('item 29 -->'+item );
for(Product2 product :[select id, name from Product2 where Id IN : PIds]){
system.debug('product 34 -->'+product );
//List<Rates_Commissions__c> rate = [select Id, Agreed_Rate__c, Product_Item__c, Client_Account__c, Venue_Hotel__c from Rates_Commissions__c where Product_Item__c =:product.Name ];
// for(Rates_Commissions__c rate :[select Id, Agreed_Rate__c, Product_Item__c, Client_Account__c,Venue_Hotel__c from Rates_Commissions__c where Product_Item__c =:product.Name ])
for(Rates_Commissions__c rate: [select id, Name, Product_Item__c, Client_Account__c, Venue_Hotel__c , Agreed_Rate__c, AgreedRes__c from Rates_Commissions__c where Product_Item__c =: product.id ])
{
system.debug('rate 42 -->'+rate );
if(quotes.AccountId == rate.Client_Account__c && quotes.Venue__c == rate.Venue_Hotel__c)
{
rate.Agreed_Rate__c = item.PSL_Rate__C;
rate.AgreedRes__c = item.Commission_Percentage_PSL__c;
}
}
}
}
}
}
} //if quote
// (quotes.AccountId == rate.Client_Account__c AND quotes.Venue__c == rate.Venue_Hotel__c)
/* if(quotes.AccountId == rate.Client_Account__c && quotes.Venue__c == rate.Venue_Hotel__c)
{
rate.Agreed_Rate__c = item.PSL_Rate__C;
rate.AgreedRes__c = item.Commission_Percentage_PSL__c;
}
*/
// select Id,agrredrate from rate ommison where productrc=pid && ratecommison.clinetacc=quoteacc && ratecommisonvenue = qotevenue ====== Client_Account__c,Venue_Hotel__c from Rates_Commissions__c where Product_Item__c =:item.Product2Id
}
Thanks , Utkarsha
I am writing a code where i am almost done. but i dont know how to get rid of this error. I want to compare accounts on quote object and one of the object which is child object (rate and commision) of product object. When this 2 are same then i want to update field on rate and commision object on quote line item object. can anyone help me with this?
trigger UpdateAgreedRate on QuoteLineItem (before insert, before update) {
system.debug('****************InTrigger**********************');
if(trigger.isBefore && (trigger.isInsert || trigger.isUpdate)){
String QuoteID ;
set<id> PIds = new set<id>();
for (QuoteLineItem childObj : Trigger.new) {
if(QuoteID == null) {
QuoteID = childObj.QuoteID;
}
if(childObj.Product2Id != null){
PIds.add(childObj.Product2Id);
}
}
system.debug('QuoteID 19 -->'+QuoteID );
if(QuoteID != null) {
List<Quote> quotes = [select Id, AccountId, Venue__c from Quote where Id =:QuoteID ];
if(quotes.size() > 0) {
Quote QuoteDetails = quotes[0];
system.debug('QuoteDetails 26 -->'+QuoteDetails );
for (QuoteLineItem item : Trigger.new) {
system.debug('item 29 -->'+item );
for(Product2 product :[select id, name from Product2 where Id IN : PIds]){
system.debug('product 34 -->'+product );
//List<Rates_Commissions__c> rate = [select Id, Agreed_Rate__c, Product_Item__c, Client_Account__c, Venue_Hotel__c from Rates_Commissions__c where Product_Item__c =:product.Name ];
// for(Rates_Commissions__c rate :[select Id, Agreed_Rate__c, Product_Item__c, Client_Account__c,Venue_Hotel__c from Rates_Commissions__c where Product_Item__c =:product.Name ])
for(Rates_Commissions__c rate: [select id, Name, Product_Item__c, Client_Account__c, Venue_Hotel__c , Agreed_Rate__c, AgreedRes__c from Rates_Commissions__c where Product_Item__c =: product.id ])
{
system.debug('rate 42 -->'+rate );
if(quotes.AccountId == rate.Client_Account__c && quotes.Venue__c == rate.Venue_Hotel__c)
{
rate.Agreed_Rate__c = item.PSL_Rate__C;
rate.AgreedRes__c = item.Commission_Percentage_PSL__c;
}
}
}
}
}
}
} //if quote
// (quotes.AccountId == rate.Client_Account__c AND quotes.Venue__c == rate.Venue_Hotel__c)
/* if(quotes.AccountId == rate.Client_Account__c && quotes.Venue__c == rate.Venue_Hotel__c)
{
rate.Agreed_Rate__c = item.PSL_Rate__C;
rate.AgreedRes__c = item.Commission_Percentage_PSL__c;
}
*/
// select Id,agrredrate from rate ommison where productrc=pid && ratecommison.clinetacc=quoteacc && ratecommisonvenue = qotevenue ====== Client_Account__c,Venue_Hotel__c from Rates_Commissions__c where Product_Item__c =:item.Product2Id
}
Thanks , Utkarsha
All Answers
Thank you Waqar
But now , folowing statements are not updating. I want to store value in rate.Agreed_Rate__c to item.PSL_Rate__C;
when i debug it. its giving me null value.
rate.Agreed_Rate__c = item.PSL_Rate__C;
rate.AgreedRes__c = item.Commission_Percentage_PSL__c;
I have made stilly mistake
rate.Agreed_Rate__c = item.PSL_Rate__C;
rate.AgreedRes__c = item.Commission_Percentage_PSL__c;
It should be
item.PSL_Rate__C = rate.Agreed_Rate__c ;
item.Commission_Percentage_PSL__c = rate.AgreedRes__c ;
Now its updating value