You need to sign in to do that
Don't have an account?
Keith Stephens 18
rest api dynamic soql
Hello all,
I am making a rest api call from the developer console that just calls SF AIP /query?q passing in a simple SOQL statment.
salesforce.com/services/data/v40.0/query?q=SELECT+Attny_Phone_From_Contact__c,Attorney_Email_from_Contact__c,Attorney_Email__c,Attorney_Fax__c,Attorney_First_Name__c,Attorney_Full_Name__c,Attorney_Last_Name__c,Id,Plaintiff_First_Name__c,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c+FROM+Case+limit+3';
This works fine, but now I want to add the logged in users email address, everything I have tried is not working.
example String userEmail = UserInfo.getUserEmail();
And adding userEmail in my soql string ect..
How can I get the email to be passed in the query.
Thanks,
Keith.
I am making a rest api call from the developer console that just calls SF AIP /query?q passing in a simple SOQL statment.
salesforce.com/services/data/v40.0/query?q=SELECT+Attny_Phone_From_Contact__c,Attorney_Email_from_Contact__c,Attorney_Email__c,Attorney_Fax__c,Attorney_First_Name__c,Attorney_Full_Name__c,Attorney_Last_Name__c,Id,Plaintiff_First_Name__c,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c+FROM+Case+limit+3';
This works fine, but now I want to add the logged in users email address, everything I have tried is not working.
example String userEmail = UserInfo.getUserEmail();
And adding userEmail in my soql string ect..
How can I get the email to be passed in the query.
Thanks,
Keith.
Hi Keith,
You just need to be careful about properly escaping quotes in the query.
Here's what a valid query request looks like in workbench:
For your example, you just need to plug in the userEmail field in the correct place and escape the single quotes accordingly. The string should look like:
'/services/data/v40.0/query?q=SELECT+Attny_Phone_From_Contact__c,Attorney_Email_from_Contact__c,Attorney_Email__c,Attorney_Fax__c,Attorney_First_Name__c,Attorney_Full_Name__c,Attorney_Last_Name__c,Id,Plaintiff_First_Name__c,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c+FROM+Case+WHERE+Attorney_Email_from_Contact__c=\''+userEmail+'\'+limit+3';
for readability sake I shorted the query, but this is what I want to do.
query?q=select Attorney_Full_Name,\''+userEmail + '\'+from+case+limit 3'; I do not want the where clause that you added.
Thanks,
Keith.