function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vigneshwaran LoganathanVigneshwaran Loganathan 

Error: Compile Error: Invalid bind expression type of Schema.SObjectField for column of type Date at line 18 column 238

trigger AssignPhysicalTherapist on Engagement_Category__c (before insert, before update)
{
  list<Physical_therepist__c> phyt= new list<Physical_therepist__c>();
  list<Physical_therepist__c> phyt1= new list<Physical_therepist__c>();
  list<Engagement_Category__c> engc= new list<Engagement_Category__c>();
  list<Engagement_Category__c> engcat= new list<Engagement_Category__c>();
  //physical_therapist__c phyter5= new Physical_therapist__c();
  map<id,Engagement_Category__c> maps= new map<id,Engagement_Category__c>();
  set<id> phyid= new set<id>();
 engc=[select name,id, Account__c,date__c,date1__c from Engagement_Category__c where id!= null];
 integer count1= [select count() from Engagement_Category__c where id!= null];
 //phyt=[select id,Appoint_Date__c,name,booked__c,engagement_category__c,appoint_end_date__c,startdate__c,enddate__c from Physical_Therepist__c where account__C!=: null and id !=: null AND (startdate__c <=: Engagement_category__c.date1__c) and (enddate__c >=: Engagement_category__c.date1__c) AND (booked__c=false) limit 1];
 //system.debug('>>>phyt'+phyt);
 integer count= [select count() from Physical_Therepist__c where account__C=null and id != null];
 system.debug('>>>count phy'+count);
 for(Engagement_category__c engx:Trigger.new)
 {
   for(Physical_therepist__c physx:[select id,Appoint_Date__c,name,booked__c,engagement_category__c,appoint_end_date__c,startdate__c,enddate__c from Physical_Therepist__c where account__C!=: null and id !=: null AND (Appoint_Date__c <=: Engagement_category__c.Date__c) and (enddate__c >=: Engagement_category__c.date1__c) AND (booked__c=false) limit 1]) // Error at this Line 
   {      
       physx.booked__c=true;
       system.debug('>>>>>booked'+physx.booked__c);
       engx.Physical_Therepist__c= physx.id;
       engx.Therapist__c=physx.name;
       engx.engagement__c='a@a.com';
       system.debug('>>> engx.Physical_Therepist__c'+  engx.Therapist__c);
       engcat.add(engx);   
       phyt1.add(physx);               
   }
 }
}
Hi,

I have got the Error in the Mentioned line, what is the Reason for it?

Thanks,
 
Best Answer chosen by Vigneshwaran Loganathan
ManojjenaManojjena
HI Vigneshwaran,

The problem you made in your query is inplace of  (engx ) variable of Trigger .new you have added Engagement_category__c .So repalce engx with Engagement_category__c will resolve your issue .
Also you have added binding operator every where while comparing with null as well ,I think it is not requred still it will not throw you error .
for(Physical_therepist__c physx:[select id,Appoint_Date__c,name,booked__c,engagement_category__c,appoint_end_date__c,startdate__c,
   enddate__c from Physical_Therepist__c where account__C != null and id !=:null AND (Appoint_Date__c <=: engx.Date__c) and (enddate__c >=: engx.date1__c) AND (booked__c=false) limit 1])

Please let me know any issue .

All Answers

Himanshu ParasharHimanshu Parashar
Hi,

Try after replacing your for loop synax as follow
 
for(Physical_therepist__c physx:[select id,Appoint_Date__c,name,booked__c,engagement_category__c,appoint_end_date__c,startdate__c,enddate__c from Physical_Therepist__c where account__C!=null and id !=null AND (Appoint_Date__c <=: Engagement_category__c.Date__c) and (enddate__c >=: Engagement_category__c.date1__c) AND (booked__c=false) limit 1]) // Error at this Line


Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
 
Vigneshwaran LoganathanVigneshwaran Loganathan
Hi Himanshu,

Thanks for the reply, But it still shows the same, Could you Explain what the Error means?
 
ManojjenaManojjena
HI Vigneshwaran,

The problem you made in your query is inplace of  (engx ) variable of Trigger .new you have added Engagement_category__c .So repalce engx with Engagement_category__c will resolve your issue .
Also you have added binding operator every where while comparing with null as well ,I think it is not requred still it will not throw you error .
for(Physical_therepist__c physx:[select id,Appoint_Date__c,name,booked__c,engagement_category__c,appoint_end_date__c,startdate__c,
   enddate__c from Physical_Therepist__c where account__C != null and id !=:null AND (Appoint_Date__c <=: engx.Date__c) and (enddate__c >=: engx.date1__c) AND (booked__c=false) limit 1])

Please let me know any issue .
This was selected as the best answer
Himanshu ParasharHimanshu Parashar
Hi,

the problem is with data type mismatch between

Appoint_Date__c <=: Engagement_category__c.Date__c

Please check them they should be same type.


Thanks,
Himanshu
Vigneshwaran LoganathanVigneshwaran Loganathan
Thank you Manoj, I almost forgot it.
Thanks Himanshu for Explaining what the Error is :)
 
nishad basha 7nishad basha 7
Hi,  Manoj Kumar jena

How to create a high volume customer portal user using visualforce page?
iam getting this error type how to solve the above scenario please give some ideas with examples.

  Errors
Contact: Cannot create a portal user without contact
    Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Cannot create a portal user without contact: [ContactId] once i give the details same error will occur in both Accounts