You need to sign in to do that
Don't have an account?
pradeep m 27
Compile Error: No such column 'color__c' on entity 'Product2'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. at line 9 column 3
trigger oppLineTrigger on OpportunityLineItem (before insert) {
Set<Id> pbeIds = new Set<Id>();
for (OpportunityLineItem oli : Trigger.new)
pbeIds.add(oli.pricebookentryid);
Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>(
[select Product2.color__c from PricebookEntry where id in :pbeIds]);
for (OpportunityLineItem oli : Trigger.new)
oli.color__c = entries.get(oli.pricebookEntryId).product2.color__c;
}
Set<Id> pbeIds = new Set<Id>();
for (OpportunityLineItem oli : Trigger.new)
pbeIds.add(oli.pricebookentryid);
Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>(
[select Product2.color__c from PricebookEntry where id in :pbeIds]);
for (OpportunityLineItem oli : Trigger.new)
oli.color__c = entries.get(oli.pricebookEntryId).product2.color__c;
}
I think it might be a permission issue, please check if the concerned user has access to fields in this customobject "color".
Please check the link below
http://salesforce.stackexchange.com/questions/50824/invalid-field-username-on-user-soql-query
Best Regards
Naga Kiran
NOTE:- Please follow below Step to fix this issue
1) Please check API Name of field Color on Product2 object and "OpportunityLineItem"
2) Please provide Field level access of both field to all user.
Please let us know if this will help you
Thanks
Amit Chaudhary