+ Start a Discussion
R_ShriR_Shri 

what does this method whereOrAndClause () do?

Hi,

 

I was just watching a an APEX webinar @ http://wiki.developerforce.com/page/Webinar:_Intro_to_Apex_Code_(2012-July)

 

There I came accross a code (@ time approx. 48min. of video)

 

 String query String = 'SELECT name, celebrity__c, celebrity_r.name, destination__c,city__c,status__c' + 
                                        'FROM reservation__c';
 
         if(reservationNum != null && reservationNum != ' '){
            reservationNum = string.escapeSingleQuotes(reservationNum); // To Avoid SOQL Injection
            reservationNum = reservationNum.startswith('%') ? reservationNum : '%' + reservationNum ;
            reservationNum = reservationNum.endswith('%') ? reservationNum : reservationNum +  '%' ;
            queryString += whereOrAndClause() + 'Name like\'' + reservationNum + \'';
         }
 
Here I couldn't understand what does whereOrAndClause()  do ? What would be its return type (I think it should be String) ?
Can anybody please suggest what should be written in this method?
 
Thanks in advance.:)
I am quite new to APEX programming.
UVUV

My Friend, There is no such method in salesforce. This 'whereOrAndClause' tells you that you can add where condition with or/and clause. Its up to you how you design your query. 

R_ShriR_Shri

@ UV

 

Can you please elaborate it?

Sorry, I didn't understood much about "where condition with or/and clause"

Do we have to again write the query in this method with where condition, or we have to write sth else.

(In original code 4 times they have written a similar IF condition but same variable(querying) is used everytime, with different conditions.)

 

 

P.S. : Is there any other method also to make VF page, which has functionality of Search based on some(say 4 or 5) conditions ? 

UVUV

Pls go through it..

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_sosl_where.htm

 

There is no std search component provided by salesforce . If you want to have search functionality, pls develop your own component.