Emilio Taylor
Posts: 0
Joined: Thu Jul 03, 2014 11:33 am

How do I pass parameters into a Salesforce Query?

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":[

    ]
    }

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

How do I pass parameters into a Salesforce Query?

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

Emilio Taylor
Posts: 0
Joined: Thu Jul 03, 2014 11:33 am

How do I pass parameters into a Salesforce Query?

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

How do I pass parameters into a Salesforce Query?

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

Emilio Taylor
Posts: 0
Joined: Thu Jul 03, 2014 11:33 am

How do I pass parameters into a Salesforce Query?

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

Return to “Issues”