Query Task Where clause using object variable
Hi everyone,
I have written a basic workflow that will allow a user to search out Lot and Concession features using 2 search criteia. In a Display Form the user is prompted for the lot number from an Autocomplete Box (the Lot variable is defined as a string), then a List Box is used to narrow down the choices with the Lot AutoComplete Box driving the Cascading ID. Resulting in only those Concession records that have the Lot number from the first step are displayed in the pick list (this Concession variable is stored as an object).
I can't seem to figure out how to write the Where clause in the QueryTask that will select only those features that have the Lot AND Concession picked by the user. I've been trying to use the following expression, but keep getting a compiler error for the resultConcession variable.
"LOT = '" + resultLotNum + "' AND CONCESSION = '" + resultConcession + "'"
I'm fairly new to coding so any additional explanation would be welcomed.
Thanks,
Gary
0
-
Gary, Try this:
"LOT = '" + resultLotNum + "' AND CONCESSION = '" + resultConcession.ToString + "'"
The object has to be converted to a string. Make sure Intellisence is turned on in Workflow Designer. When you type the word resultConcession and add a period, syntax will appear as shown below:
_img_ alt="User-added image" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=907f2000000XeH9&feoid=Body&refid=0EMf2000000YDUQ" _/_img_
Rick0 -
Hi Rick,
Thanks for the help with the expression and the Intellisence tip as well.
Cheers,
Gary0 -
A small tip in addition to Richard's answer. I always recommend using the String.Format() method to keep things readable, e.g. String.Format("LOT = '{0}' AND CONCESSION = '{1}'", resultLotNum, resultConcession)
Note that if resultLotNum or resultConcession could contain a single quote, you will have to escape them.0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
3 kommentarer