1

I have a webservice method that takes the $_REQUEST from the URL parameter of my app and I believe handles it like an array, for example:

inputs.param1 = "some_value"
inputs.param2 = "1209845, 2348425876, 2958263459, etc"

In Chrome developer tools it looks like this

enter image description here

But now I need to use the "Ids" parameter to make up a dynamic SOQL query in the WHERE statement. I assume I can get the parameter from my inputs variable by referring to the ids attribute of the variable like this

inputs.ids

Which should equate to "####, ####, ####", but I am not sure if SF considers this an <Array> or a <String>.

Either way, I need to convert this parameter to a <String> with each Id # wrapped in single-quotes. So that I can have a WHERE statement like this work: WHERE Id IN :ids

1
  • you are using dynamic soql or static (compiled) soql ?
    – cropredy
    Commented Jan 1, 2015 at 0:14

1 Answer 1

4

As for how the controller sees it, I believe you can pass a Javascript array to the controller during remote methods if the signature of the remote method is using a String[]. If it is just using a string then the array will be passed as a string.

Typically you would take the string, split it into an array and use it in the sql:

i.e.

String s = 'a,b,c,d,e,f';

String[] string_array = s.split(',');

then you use it in the sql

dynamic:

'Select ID From Account where field in :string_array';

or regular

[Select ID From Account where field in :string_array];
1
  • What if I needed to add 2 objects from my input together? For example: String[] starting_id = inputs.first_id+','; (which is not an array, just a string) AND String[] string_ids = inputs.ids.split(','); Commented Jan 6, 2015 at 20:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .