0

here is the query i am using:

bilan1 = [select id,valider__c,poste__c,Statut__c,Poste__r.Date_dernier_bilan__c, date_bilan__c, moyenne_du_bilan__c from Bilan_de_positionnement__c where poste__c in: collID and date_bilan__c =:Poste__r.Date_dernier_bilan__c  order by date_bilan__c asc];

i get this error:

Variable does not exist: Poste__r.Date_dernier_bilan__c

when i remove the condition and date_bilan__c =:Poste__r.Date_dernier_bilan__c the error disappears even though the Poste__r.Date_dernier_bilan__cfield is fetched in the query meaning that the variable Poste__r.Date_dernier_bilan__c does exist, am i messing something ?

0

1 Answer 1

0

i think you don not need : match fields. : for variables. so query should be like :

bilan1 = [select id,valider__c,poste__c,Statut__c,Poste__r.Date_dernier_bilan__c, date_bilan__c, moyenne_du_bilan__c from Bilan_de_positionnement__c where poste__c in: collID and date_bilan__c = Poste__r.Date_dernier_bilan__c  order by date_bilan__c asc];

it might help you.

5
  • I get another error: expecting a colon, found 'Poste__r.Date_dernier_bilan__c', so i think the colon is required Commented May 20, 2016 at 9:26
  • 2
    You can't do it like that, you can use only apex variables for such comparison or create another sub-select but it won't work as it support only Id fields. So the only way is first get those dates in apex variable and then do a select. Commented May 20, 2016 at 9:29
  • @ Oles Malkov i will try that right away Commented May 20, 2016 at 9:32
  • @ Oles Malkov can't we write sub-query ?? Commented May 20, 2016 at 9:33
  • at least the code get saved without errors this time, i will check if the results are as expected Commented May 20, 2016 at 9:35

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