You need to sign in to do that
Don't have an account?
Jeeedeee
SOSL in Apex and OR function is it supported?
Hi all,
From the docs in Salesforce I see we can use the OR logic in the SOSL query. I am trying to search for both postal code and a phone number. I would like to get back Accounts, and maybe in the future also accounts...
I keep getting save/compile errors, tried many ways of querying, but no luck yet... Does anyone have tried this before in apex (custom controller)
[code]
String phoneNr = ApexPages.currentPage().getParameters().get(PARAMETER_KEY_PHONE_NR);
String postalCode = ApexPages.currentPage().getParameters().get(PARAMETER_KEY_POSTAL_CODE);
List<List<SObject>> searchList = [FIND {:phoneNr OR :postalCode} IN ALL FIELDS RETURNING Account (Id, Name)]; // this does not save
List<List<SObject>> searchList = [FIND '0612341234 'OR '1000AA' IN ALL FIELDS RETURNING Account (Id, Name)]; // hardcoding also did not save
[/code]
Thanks! JD
From the docs in Salesforce I see we can use the OR logic in the SOSL query. I am trying to search for both postal code and a phone number. I would like to get back Accounts, and maybe in the future also accounts...
I keep getting save/compile errors, tried many ways of querying, but no luck yet... Does anyone have tried this before in apex (custom controller)
[code]
String phoneNr = ApexPages.currentPage().getParameters().get(PARAMETER_KEY_PHONE_NR);
String postalCode = ApexPages.currentPage().getParameters().get(PARAMETER_KEY_POSTAL_CODE);
List<List<SObject>> searchList = [FIND {:phoneNr OR :postalCode} IN ALL FIELDS RETURNING Account (Id, Name)]; // this does not save
List<List<SObject>> searchList = [FIND '0612341234 'OR '1000AA' IN ALL FIELDS RETURNING Account (Id, Name)]; // hardcoding also did not save
[/code]
Thanks! JD
Please follow the link regarding OR operator in APEX.
http://www85.homepage.villanova.edu/timothy.ay/MIS2040/Secure2/Apex-cheatsheet.pdf
https://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_expressions_operators_understanding.htm
http://www.salesforce.com/us/developer/docs/soql_sosl/index_Left.htm
http://www.salesforce.com/us/developer/docs/dbcom_soql_sosl/Content/sforce_api_calls_soql_select_comparisonoperators.htm
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_comparisonoperators.htm
Thanks
Vikash_SFDC