Zum Hauptinhalt gehen

Workflow QueryTask unique values

Kommentare

13 Kommentare

  • Jeff Pope

    I did notice that when I select the actual features found from the query, that the OBJECTID is no longer repeated and the number is reduced. Is there a way to have it run the QueryTask and select distinct or unique values from the OBJECTID column?

    0
  • Permanently deleted user

    Hi Jeff,

    Did you ever get this figured out?  I am having a similar issue when using a combo box who's values are based off a field, there seems to be no way to select distinct so that the values don't repeat again and again.

    0
  • Jeff Pope

    No I didn't. Still working on it. Kind of frustrating :(

    0
  • Permanently deleted user

     I believe the Geocortex team is working on adding the ability to select distinct field values for forms.  About 3 weeks ago, I saw a post on that. 

    In the meantime, you could create a pivot or summary table with the values and add that table to the map service, then use that field to populate the dropdown.  The table can also include other items that you would use in your workflows so think about it's design first.  I put a config table in the service that contains layers that I might want to query, values that are commonly used, stuff like that.   In this case the fields are not related to the record.   Then when I query one of the fields I add a where clause like LAYER_NAME  IS NOT NULL. 

     

     

    0
  • Permanently deleted user

    There is another way to populate the combobox with the unique list item which is from QueryTask before a new GE will support.

    Here is the one I tried to make it work with GE 3.5.0.

    This is the summary

    (1) Use the "Input Data" on the Display Form as the data source of the combo box, rather than using QueryTaskUrl/1=1 whereclause

    (2) Create the a sequence where you will create the unique list item with few steps.

     

    This is the detailed information:

    (1) Create a variable say 'listInput" as List<DataItem>

    (2) Create a sequence before the DisplayForm.

    • QueryTask to get all values (with 1=1 whereclause) of the field you are interested to populate the combobox, whose result will be FeatureSet
    • Add ForEach<Graphic> activity after then, where loop through QueryResult.Features, and whose body consits of initialize the a variable of List<string> and assign the item.Attributes(fieldNameInterested).ToString(), and add to the collection, List<string> using "AddToCollection<T>".
    • If you want to sort the list, use InvokeMethod (a Common Server activity) activity to sort List<string> with MethodName "Sort"
    • Then Use List To DataItem List (a Conversion activity) to convert the List<string> to List<DataItem> wich is the "listInput"  on the step 1 and will be the "Input Data" of the combo box data source.

    Wish this may help someone to want to use only workflow activities to populate the Form Control with the unique values.

    From a service project developers in Latitude Geographics.

     

    0
  • Permanently deleted user

    Munwhan,

    This has been very helpful.  I got the workflow to work except for the Sort part. 

    •If you want to sort the list, use InvokeMethod (a Common Server activity) activity to sort List<string> with MethodName "Sort"

     I always get the Error Icon in the right corner of the Activity Bar - so I know I don't have it set up right.

    The following is the documentation on the Invoke Method

     

    GenericTypeArguments

     

    The generic type arguments of the contained method.

     

     

    MethodName

     

    The name of the method to run, specified without parameters.

     

     

    Parameters

     

    The parameter collection of the method to be invoked.

     

     

    Result

     

    The name of a variable or argument that will hold the return value from the method’s execution.

     

     

    RunAsynchronously:

     

    True if the method should be run asynchronously, False otherwise.

     

     

    TargetObject

     

    If the MethodName specifies a public instance method, the TargetObject should specify the name of a variable or argument that the method should be invoked upon. One of TargetObject or TargetType must be specified.

     

     

    TargetType

     

    If the MethodName specifies a public static method, the TargetType should specify the type that the method is defined for. One of TargetObject or TargetType must be specified.

     

    I set my values to the following:

    GenericTypeArguments - none

    MethodName - Sort 

    Parameters - none

    Result - if you do a sort on a list, do you have to assign the result to a new variable?  I tried it with a new list variable but it didn't work.  I tried it with the fieldValueList variable and that didn't work either.

    TargetObject - fieldValuesList

    TargetType - System.Collections.Generic.List<System.String>

    If you could, please let me know what I'm missing in my InvokeMethod. 

    Thanks very much,

    Sonia

     

     

     

     

     

     

    0
  • Permanently deleted user

    I was also able to get a list of unique values by publishing a query layer in my map document.  (ArcMap->File->Add Data->Query Layer) Essentially, you can create a dynamic table that is based on a SQL table (or a feature class).  Just used a distinct flag in your SQL statement.  Query layers are handy for creating composite fields. 

    0
  • Permanently deleted user

    hi, Sonia,

    To sort List<String> using the InvokeMethod on the GeortexWorkflowDesigner, please follow these step:

    (1) Assumed that you have already the populated List<String> with the variable named say "listValues"

    (2) Drag/Drop the InvokeMethod control from Toolbox

    (3) Do not change anything on the Properties of the InvokeMethod (simply use the default)

    (4) On theINvokeMethod control, Set TargetType (null) as it was, Type "listValues" on the TargetObject, and finally Type "Sort" on the MethodName.

    That is it After then, your "listValues" is sorted out of the InvokeMethod.

     

    By the way, there is a "SortFeatureSet" Common Server control now on the GE 3.7 after.

    Hope this help you out.

     

    Munhwan

    0
  • Permanently deleted user

    Jake,

    I agree.

    It will be the better to create a VIEW (with GroupBy or Distinct), and publish it to the Table to the MXD, and then you can use with QueryTask against the Table of the mapservice to get the datasource of the FORM control like ListBox/ComboBox.

    Munhwan

    0
  • Permanently deleted user

    I like Jake's Idea also, especially when you need to get distinct values.  

    Munwhan, thank you so much for the instructions on the InvokeMethod.  It still didn't work for me.  I must have something wrong with the way I set up the variables.

    However, I used the featureset sort and that did work.   Here's the (https://support.geocortex.com/Data/Sites/1/userfiles/1486/workflow_getfieldvaluesinaform.xaml) GetFieldValues workflow which is set to an ESRI service so it should work for anyone.  The process was built to populate a different workflow that required the dropdown lists to be more dynamic than a hard-coded map service url in the form.

    Thanks very much for all of your help.

    Sonia

    0
  • Permanently deleted user

    Isn't it annoying to set the hard-coded map service url in the form for the ListBox/ComboBox control, right?

    For your interest, I heard that the supprting the dynamic parameter on the workflow form is the top priority to implement. 

    It will be so helpful not to do any preprocess to set the datasource for the form.

    cheers,

    Munhwan

    0
  • Permanently deleted user

    Even better: use the ArcGIS Querylayer with the SQL you want and publish it next to your layer in the mapservice.

     

     

    0
  • Permanently deleted user

    I know this thread is old, but apparently this new feature GeoCortex that was supposed to be released either isn't released or is hidden in another tool in the workflow....

    I am using a cascading combobox (just like the Schools example except one single layer, 2 fields)

    It is Recycling Materials by cities.  So I have the user select a material (Field: MATERIAL) they need to recycle, then the box below populates with all the cities (Field: LOCATIONCITY) that contain a facitity of that type.

    I am storing OBJECTID in the second combobox so that I can return only those facilities within the city of that material type.  This causes multiple values of the same to show up in the combobox.

    How do I show ONLY unique values???

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.