Page 1 of 1

How do I pass parameters into a Salesforce Query?

Posted: Fri Jul 04, 2014 5:56 pm
by Emilio Taylor

How do I pass parameters into a Salesforce Query?

For example:

  • I have an input component for Name

  • In my Salesforce Query Contact Service, I have the following query:

  • SELECT Name FROM Contact

  • However, I want to only retrieve Contacts that match, or are like the value inputted

  • Should I change the service, and add a new Parameter for Name, and change the query to this:

  • SELECT Name FROM Contact WHERE Name like '%{Name}%'

  • Or, is there another way to retrieve values based on search parameters in a Salesforce Query Service?

    When I perform a test in the Service, I get a Test Successful, but retrieve no results:

    {
    "totalSize":0,
    "done":true,
    "records":[

    ]
    }


How do I pass parameters into a Salesforce Query?

Posted: Fri Jul 04, 2014 6:34 pm
by Kateryna Grynko

Hi Emilio,

Map input to request parameter 'q' and add the following JS code to mapping:precodereturn "SELECT Name FROM Contact WHERE Name like '%" + value + "%' &quot/code/pre


How do I pass parameters into a Salesforce Query?

Posted: Sat Jul 05, 2014 12:48 am
by Emilio Taylor

Hello Katya,

I looked closer at your example, and I see what you mean.

Since I'm passing the data from my component, the "value" is what I mapped in, so when I add what you've provided, it allows me to see what I expect.

Thanks again!

Emilio


How do I pass parameters into a Salesforce Query?

Posted: Tue Jul 08, 2014 5:21 pm
by Evgene Karachevtsev

Hello Emilio,

You should use following code

codereturn "SELECT id FROM Contact WHERE Username__c like '%" + value + "%' &quot/code

Variable value in the mapping contains the value that was mapped


How do I pass parameters into a Salesforce Query?

Posted: Tue Jul 08, 2014 5:25 pm
by Emilio Taylor

Thanks Evgene. This response was perfect. I was able to use Katya and now your responses to get me through the issue I was having! I absolutely love Appery! Your support team is great as well! Highly recommended