Dynamic input for query.outFields

618
3
06-26-2012 10:41 AM
SamirGambhir
Occasional Contributor III
Hi,
I a trying to build the query.outFields as a string input based on field selection by user. e.g. If the user selects Crude Birth Rate from the form, I would like to pass field attribute as "CBR_01". I am trying to build this in JavaScript like this:

....
if (valueB=="Crude Birth Rate"){
            var valOutB="CBR_01";
          }
...
var myIndString = "['"+valOutB+"']";

query.outFields = myIndString;
....

This doesn't seem the right way of doing it as it does not execute the query. Any thoughts?
Thanks
Samir
0 Kudos
3 Replies
SamirGambhir
Occasional Contributor III
Apparently, Silverlight API has a method '.add' for query.outFields. Is there a similar one for JavaScript API as well? query.outFields.add("XYZ") will be perfect but it does not work in JavaScript API.
Please help
Samir
0 Kudos
MattLane
Occasional Contributor II
outFields is an array of string objects, javascript uses .push() to add to an array.
0 Kudos
SamirGambhir
Occasional Contributor III
Hi Matt,
Thanks for your response. Unfortunately, '.push()' did not work with my code. I tried a different route instead. I passed all fields in the query.outFields, and then checked the results against the indicators that the user selected. It has worked for me well.
Thanks for your help,
Samir
0 Kudos