|
|
睿智的柿子 · 基于3D激光扫描技术的粗集料三维形态特征分析· 1 年前 · |
|
|
微笑的花生 · 【子平金鉴】八字真言、捷驰千里马_网易订阅· 1 年前 · |
|
|
耍酷的马克杯 · 元旦假期北京重点商圈客流量增四成_深圳新闻网· 1 年前 · |
|
|
儒雅的椅子 · 你有多乐观,就有多快乐_熊生_大熊猫_奇思· 2 年前 · |
|
|
讲道义的鸡蛋
2 年前 |
|
|
睿智的柿子 · 基于3D激光扫描技术的粗集料三维形态特征分析 1 年前 |
|
|
微笑的花生 · 【子平金鉴】八字真言、捷驰千里马_网易订阅 1 年前 |
|
|
耍酷的马克杯 · 元旦假期北京重点商圈客流量增四成_深圳新闻网 1 年前 |
|
|
儒雅的椅子 · 你有多乐观,就有多快乐_熊生_大熊猫_奇思 2 年前 |
The error is in your query string...If in ytour searchChm method control will not go inside any if condition then your final query string will be
Querystring>>>>SELECT id,firstname,lastname,email from Contact Where
Above string has no meaning because there is nothing after where ..
you can simply check in the end if there is nothing after where then remove where also to resolve the error..
Please check and let me know if this helps you
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.
Thanks,
Sandeep
Salesforce Certified Developer
You can simply replace your method with this method
public PageReference searchm(){ String querystring='SELECT id,firstname,lastname,email from Contact'; if(contList.firstname!=null && contList.lastname==null && contList.Email==null){ querystring += ' where firstname =\''+cont.firstname+'\''; }else if(contList.firstname!=null && contList.lastname!=null && contList.Email==null){ querystring += ' where firstname =\''+contList.firstname+'\'' +'and'+' '+'lastname =\''+contList.lastname+'\''; }else if(contList.firstname!=null && contList.lastname!=null && contList.Email!=null){ querystring += ' where firstname =\''+contList.firstname+'\'' +'and'+' '+'lastname =\''+contList.lastname+'\'' +'and'+' '+'Email =\''+contList.Email+'\''; }else if(contList.firstname==null && contList.lastname!=null && contList.Email!=null){ querystring += ' where lastname =\''+contList.lastname+'\'' +'and'+' '+'Email =\''+contList.Email+'\''; }else if(contList.firstname==null && contList.lastname==null && contList.Email!=null){ querystring += ' where Email =\''+contList.Email+'\''; }else if(contList.firstname!=null && contList.lastname==null && contList.Email!=null){ querystring += ' where firstname =\''+contList.firstname+'\'' +'and'+' '+'Email =\''+contList.Email+'\''; System.debug('Querystring>>>>'+ querystring); listContact=Database.query(querystring); System.debug('Querystring>>>>'+ querystring); return null;
I have removed where clause from main string and added where inside the loop..
Now as you have used else if ..so it will always go inside one if condition so no need to check and remove where..
You can simply replace your method wiuth above code, it will work
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.
Thanks,
Sandeep
Salesforce Certified Developer
You just need to add a space after 'where' at the line 22. Otherewise, the soql would be like 'select .... from contact wherefirstname....'.
String querystring='SELECT id,firstname,lastname,email from Contact Where ';
David
I agree with David, if control will go in any if condition then due to space it can give the same eror, but if it will not go then du eto space it can cause the same issue..
So the best solution is put where inside the conditions and provide the space..if you notice I haev provided the space before where clause to avoid spacing issue..
Please repalce your code and let us know if that helps you..
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.
Thanks,
Sandeep
Salesforce Certified Developer