0

I wrote a trigger on Contract, where I need to query all the related Quotes of contract. I wrote below query:

List<Quote> quotes = [Select ContractId From Quote Where ContractID IN: ids];

I get this error:

No such column 'ContractId' on entity 'Quote' ...

I tried to execute this query in Query Editor of Developer Console and as Anonymous apex. Both Worked. I also checked the permission for the field. In fact I can see the field on the Record's Page Layout.

What could be the problem?

6
  • 1
    Check the API Version of your trigger. It might be an older version, where the field did not exist yet.
    – itsmebasti
    Oct 21, 2017 at 18:16
  • I actually couldn't find any contract related field on the Quote in this documentation. Maybe there is a ContactId/ContractId Typo?
    – itsmebasti
    Oct 21, 2017 at 18:25
  • So yeah if it's not a standard field, take a look at the Fields page for the Quote object. It's probably a custom lookup which means the API name is more likely to be Contract__c or whatever else was chosen by the admin who set it up.
    – Charles T
    Oct 21, 2017 at 19:05
  • @CharlesT There is a standard Contract field.
    – sfdcfox
    Oct 21, 2017 at 19:27
  • @sfdcfox any idea why it is not listed in the documentation?
    – itsmebasti
    Oct 23, 2017 at 10:34

1 Answer 1

3

The Quote.ContractId field requires at least API version 31.0. Please edit your class' or trigger's metadata to at least version 31.0.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .