0

I'm trying to pull a query from SOQL explorer to erase some records. My query is trying to make sure the ID from the opportunity matches the ID for the quote presented (there are several quotes, and the only one used is has the quote ID on the "quote_for_contract" field.

Here's the query:

select Id, Name, Opportunity__r.id, IsSelectedToPresent__c, Opportunity__r.Quote_For_Contract__c from Operator_Quote__c where Id = Opportunity__r.Quote_For_Contract__c AND IsSelectedToPresent__c = false

where Quote_For_Contract__c is the ID. But I receive a binding error as I can't compare fields to see if the ID is the same.

Do I need to implement a formula field to set it to true is the ID is the same and use that field for the query?

2
  • 1
    Is that the query that is throwing the binding error? And can you add the actual error message? – NSjonas Aug 6 '15 at 19:50
  • Sorry, not the query - good question - that was the one I was trying to use with a formula I put on the opp. object. I updated the actual query - sorry about that & the error is "Bind variables only allowed in Apex code" – gato negro Aug 7 '15 at 0:46
0

Your question's wording is a bit confusing, but try the following:

select Id, 
    Name, 
    Opportunity__r.id, 
    IsSelectedToPresent__c, 
    Opportunity__r.Quote_For_Contract__c 
from Operator_Quote__c 
where Id NOT IN (SELECT Quote_For_Contract__c FROM Opportunity__c WHERE Used_for_Quote__c = true)
    AND IsSelectedToPresent__c = false
1
  • Thanks, I tried, but it wouldn't allow me to use the Opp. object in that context. I updated the initial query - thanks again for this one, it's helpful to understand better what can be used. – gato negro Aug 7 '15 at 0:48

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.