Skip to main content

List Box Multiple Select does not select a value

Comments

9 comments

  • Zack Robison
    Encountered this myself.  Definite bug, output is object[] but forms thing that it's just an object and will fuss if you try assigning the output to an array.  Just cast after the fact for now.
    0
  • Sean McClurkan
    I am casting it - to a string. That I then evaluate to see if the string/object is empty so I know whether the user has made a selection or not.  I always get the "empty" cast result - System.Object[] - instead of the content of the selection.  Not sure what you are sugesting I do instead.  What do you mean by "cast after the fact"?
    0
  • Zack Robison
    Cast to object[] first.  The return of a string-casted array of objects will just be the type, which you're getting.  Same as if you were trying to cast a list of ints... you'll get "system.generic.list<System.int32>" or whatever.  Cast to an array of objects and iterate through it to get your strings, or use string.join.
    0
  • Sean McClurkan
    I see.  I'll give that a go.  Thanks!
    0
  • Zack Robison
    Any fortune?
    0
  • Sean McClurkan
    Ok.  I've got my DisplayForm output Object cast into an array of objects.  If the user makes any selection, I can extract the resulting strings and all is well.

     

    I'm having trouble finding an evaluation for when the user makes no selection.  How do I tell if the initial object is empty?  If the cast Array has an object that is empty?  Every test I come up with gets thrown out because there is "nothing" in my cast array of objects -except the object I cast into it. If I try to evaluate the first object in the array, I get an error that it's not an instance of an object.  

     

    What's the secret decoder ring value that will let me know the user has made no selection in the ListBox?
    0
  • Zack Robison
    Ah, that's not an issue I've wrangled with yet as my lsitbox is protected by a checkbox that I use to check for the listbox output, and a validator that ensures output in that case.  So you are able to cast the object into an empty array?  In that case I'd check the length of the array using the .length method (or is it .count?).  If that output =0 then you know what (not) to do.
    0
  • Permanently deleted user
    How about adding a 'required' validation against the listbox? Then the user won't be able to proceed without selecting a value
    0
  • Sean McClurkan
    Unfortunately, not selecting any option is a valid choice for this ListBox operation. But Zack's worakaround does provide a solution, once you get the hang of it. 

     

    Here is the recipe for extracting selected values form a Listox set to Multiple selection mode:
    • Cast the FormItem ListBox Output variable - objListBoxValue - into an ArrayOfObject variable (Object[ ])
    • If the ArrayOfObject.Count() > 0 then
      • For Each<Object> in ArrayOfObject
        • Assign item.ToString  to stringOutputValue
      • ELSE
        • Assign stringOutPutValue = "System.Object[ ]" (Or whatever you want to indicate an Empty output)
    In my case, I'm asking the User to either select a feature to search within, or to Skip this step.  If they select a Search Area (City Council District, Asset Management Area, etc.), then the WHERE clause of my QueryTask needs to include the value(s) they select. If they Skip this step, then I need to know they have selected nothing and skip this part of building my WHERE clause.

     

    Thanks again to Zack Robison for the answer!
    0

Please sign in to leave a comment.