Select State from Drop down list

I’m trying to select a state from a drop down list. The input I have in my variable is “CO” or “UT” saved into a string.

In the drop down list I have all the states but they are written like, “CO-Colorado” or “UT-Utah”.

I’m using a Select Item activity, and I’m passing it my variable state = “CO”
But it always faults on the select state activity. Is that because the strings don’t match exactly?

Is there an easy way around that if so? Or what would be the best activity to use in my situation?

In your selector where you are passing the variable follow it with a * and it should work as expected.
Like:
“<webctrl id=‘loc*’ tag=‘DIV’ aaname='”+vlocation+“-*’ / >”

1 Like

I’m a little new on adding variables to selectors… I just kind of followed the format you have in your comment.
<webctrl aaname='"+state+"-*'/>
So in order to add a variable to my selector, I have to put it in Quotations, and also plus signs?
Like so:
aaname=’ “+variable+” ’ ?
Or if I’ve got it wrong can you please elaborate a little?

1 Like

Just passing your values as ‘CO*’ to the select item activity should work. If you have multiple entries starting with ‘CO*’ then i believe it will always select the first one in the list.

Thanks,
Rammohan B.

1 Like

It will actually select different states for each time someone submits the form. So it needs to be able to take any state entry that the user types.

Keep your selector within quotes " " in a single line
Then your dynamic part/ variable will be +var+ , like a concat.

like : “<webctrl aaname=’”+state+“-*’/>”

1 Like

Select State still faulted…
<webctrl aaname='&quot;+state+&quot;-*' tag='OPTION' />
This is what showed up after I typed in exactly what you typed.
I’m not sure what else to do here.

Use this
“<webctrl aaname=’”+state+“-*’ tag=‘OPTION’ />” :point_left: with all quotes

[Dont copy from here, try and edit directly in your selector with this as a reference as it may cause special characters to be copied]

I’m getting the same error, null reference. But when I debug, ‘state’ has a value of ‘AZ’
So it’s not null…

can you share your xaml? Let me have a quick look.

If the select item activity is showing CO-Colorado or UT-Utah, then you need to pass exactly as shown. You cant pass CO to the activity, you have to pass CO-Colorado.

Since you already have unique state codes (CO/UT/etc) then it might be easiest to have a separate CSV or excel file to reference for the full state name. Just insert a separate sequence in that uses the state code, looks up the full state name, then combines with the dash in between. CO → CO-Colorado. This new string should then be passed into the select item activity

The select Item activity also accepts wildcard symbols. So I just put it right in the select item,
for my input argument I put state + “-*” and it worked! Took forever to figure out, but that’s it.
SelectWithWildCard

3 Likes