+ Start a Discussion
Manjunath reddy 25Manjunath reddy 25 

Error: Compile Error: No such column 'account' on entity 'Contract'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

Hi,

I am getting error 
Error: Compile Error: No such column 'account' on entity 'Contract'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. at line 6 column 67

but I am using standard fields which are available on contract object , my code is as below, can some one help me on this.
trigger updatePicklist on Contract (before insert, before update) {
    List<id> contractIds = new list<id>();
    for(contract c : trigger.new){
        contractIds.add(c.id);
    }
    map<account,contract> contractMap = new map<account,contract>([select account,Pricebook2 from contract where account in : contractIds]);
}

 
Keyur  ModiKeyur Modi
Hi Manjunath, 

There is no such field on contract called Account , if you are trying to user standard accout field in your query or in map then you need to rework on your code.

Your code should be like this.
trigger updatePicklist on Contract (before insert, before update) {
    List<id> contractIds = new list<id>();
    for(contract c : trigger.new){
        contractIds.add(c.id);
    }
    map<Id,contract> contractMap = new map<Id,contract>();
   for(contract eachCont: [select accountId,Pricebook2 from contract where account in : contractIds]){
      contractMap.put(eachCont.accountId,eachCont); // here in this map key is accountId and value is contract related to that accountId
   }
}

Please let me know if you need more guidance on this.

Thanks,
Keyur Modi
Manjunath reddy 25Manjunath reddy 25
Hi Modi,

Thanks for you response, accountId works fine but Pricebook2 is not getting saved, it throws an error, when we check fields we can see peicebook2 is th API name,
Error: Compile Error: No such column 'Pricebook2__C' on entity 'Contract'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. at line 7 column 57
Manjunath reddy 25Manjunath reddy 25
I checked with pricebook2, and pricebook2__C for pricebook2 error is 

Error: Compile Error: No such column 'Pricebook2' on entity 'Contract'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. at line 7 column 57
Keyur  ModiKeyur Modi
Hi Manjuanath, 

As we you are using standard field you have to use pricebook2Id instead of pricebook2
 
trigger updatePicklist on Contract (before insert, before update) {
    List<id> contractIds = new list<id>();
    for(contract c : trigger.new){
        contractIds.add(c.id);
    }
    map<account,contract> contractMap = new map<account,contract>([select account,Pricebook2Id from contract where account in : contractIds]);
}

check this code I have modified 

Thanks, 
Keyur Modi 
Darshil shah 12Darshil shah 12
Error: Compile Error: No such column 'Billings_and_Target__c' on entity 'InvoiceItem__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. at line 4 column 43
 
Darshil shah 12Darshil shah 12
My code

trigger trg_billingtagets on Billings_and_Target__c (before insert,before update) {
    
    
    List<InvoiceItem__c> lstInvoiceItem = [select Id,Name,Delivery_Con_Ind_Qrtly_Billing_Target__c,Billings_and_Target__c from InvoiceItem__c where Billings_and_Target__c IN :Trigger.New];
    
    Map<Id,Double> mapInvoiceItems = new Map<Id,Double>();
    
    for(InvoiceItem__c objInvoiceItem : lstInvoiceItem)
    {
       if(mapInvoiceItems.get(objInvoiceItem.Billings_and_Target__c)  == null)
       {
            
            mapInvoiceItems.put(objInvoiceItem.Billings_and_Target__c, objInvoiceItem.Delivery_Con_Ind_Qrtly_Billing_Target__c ); 
       }
       else if(mapInvoiceItems.get(objInvoiceItem.Billings_and_Target__c)  != null)
       {
           Double tempQrtlybillingAmount = mapInvoiceItems.get(objInvoiceItem.Billings_and_Target__c);
            
            mapInoiceItems.put(objInvoiceItem.Billings_and_Target__c, tempQrtlybillingAmount + objInvoiceItem.Delivery_Con_Ind_Qrtly_Billing_Target__c ); 
       }
    }
    
    for(Billings_and_Target__c objbtr : Trigger.New) 
    {
        objbtr.Total_Revenue_Billed_YTD__c  = mapInvoiceItems.get(objbtr.Id);
    }