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?

  • 1
    Check the API Version of your trigger. It might be an older version, where the field did not exist yet. – Basti Oct 21 '17 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? – Basti Oct 21 '17 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 '17 at 19:05
  • @CharlesT There is a standard Contract field. – sfdcfox Oct 21 '17 at 19:27
  • @sfdcfox any idea why it is not listed in the documentation? – Basti Oct 23 '17 at 10:34
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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.