Select to view content in your preferred language

How to copy and customize Query Tool and to make 2nd tool?

1068
2
10-23-2013 07:31 AM
StevePickens
Emerging Contributor
I want to make some changes to the Query Tool's functionality to use in a special case query. I would like to use the original Query Tool and the new "Customized Query Tool" in the same application. How can I do this where they will both work in the same app? I want to make a completely separate tool from the original tool.

What I have is 3 different fields within my feature class that could contain the value I am searching for. I want to search all 3 fields with one query but I don't want the user to have to enter the value 3 times (once for each field). I have found where the Query Tool sets the Where Clause for a query and by using breakpoints in Visual Studio I have seen how the Where Clause is formatted for multiple fields set up with Or between them. All I want to do is change the Where Clause set up for 1 field to a string searching all 3 fields like the following:
"  ( REF_NUMBER = '1-40001') or  PROPOSED_REF_NUMBER = '1-40001' or  ALIAS_REF_NUMBER = '1-40001'" 
using
resultLayer.Where = string.Format("  ( REF_NUMBER = '{0}') or  PROPOSED_REF_NUMBER = '{0}' or  ALIAS_REF_NUMBER = '{0}'", MyVal);

MyVal is a string variable I set up to get the 1 value entered by the user on the form.

What I don't know how to do is duplicate the original tool into another tool I can use in the same application without conflicting with each other.

Thanks
Steve
0 Kudos
2 Replies
PietaSwanepoel2
Frequent Contributor
Steve,

in order for one add-in not to clash with another you have to rename the project and build a new dll (and xap)
Project properties is where you will set it

In order to change the where clause like you propose, you will need to define the fields somewhere. The query tool has been written to map a field with a supplied value. This is defined in the configuration. You might want to revisit the configuration (and front-end for that matter) to deal with the 3 to 1 mapping. Unless you just want to hard-code the thing. In that case the query tool is an overkill for the job. Might be quicker then to write your own code than to try and understand the query tool code.
0 Kudos
StevePickens
Emerging Contributor
Thanks PietaS175.
Since I never got a response to this post, I went ahead and figured it out myself. I would up needing to search 6 different fields in the same feature class for the same value and this was simply to keep me from having to add the Query Tool 6 different times to the same app, one for each field and then users having to try each one until a match was found. I just hardcoded the Where clause and it worked great. The hardest part was finding and changing the namespace to prevent conflicts with the other Query Tool. The Query Tool did everything I wanted except let me search multiple fields for only one value entered in a single field, so I didn't think it was worth trying to write my own tool. I'm torn about trying to learn the Silverlight environment when I see almost no activity in the forum or the blog about it and no new stuff from ESRI. I'm just using the Viewer for Silverlight so that I can make some apps without writing much code. 

Again, Thanks for your reply.
Steve
0 Kudos