Checking for a value in a repating field

S

Scott

I have a repeating text field named "Divisions" that I have bound to a
Multiple-Selection listbox. I am trying to compose a rule (on a button
in the form) with a condition that simply checks to see if a particular
string (ex., "Division A") is one of the values selected in the
listbox. No matter what I try, it never returns true when "Division A"
is selected in the listbox.

Logically I'm trying to say....if (any value in Divisions = "Division
A") then...

Can anyone help me?
 
B

Ben Walters

Hey Scott there are 2 ways to achieve this functionality.
1: The first uses managed code connected to the click event of your button,
use an Xpath query to get all the nodes whose value = Divisions. So your
Xpath would look something like

/my:Fields/my:Group[my:DropDownField="Divisions"]

the logic around this would basically check to see if you got any nodes
back. If you didn't then you return false from your button and if you do get
something back you return true

2: The second option uses the rules engine within the InfoPath designer. In
addition to your drop down field you will also need a possible 2 additional
fields
1 field to track the number of times Division has been selected in the
repeating table
1 field to set to true or false

so in our "tracker" field open the properties and then open the default
value expression editor indicated by the italic FX.
Click the Insert a function button and insert a "count" function.
In the formula text box double click the "Click here to insert a field" text
When select the your drop down field then before closing the field selector
window click the "filter data" button in the bottom left hand corner. This
will open the condition editor.
The first drop down should already be set to your drop down field.
the second is usually set to "equals" and in the thir click the drop down
and select "Enter Text"
Enter "Divisions" then click ok
click ok to close all remaining open windows

this field will now display the number of times Divisions has been selected
in your repeating table. From here you can either use your button to query
the tracker field and if it's greater than 0 then return true and if it's
less than 1 return false
or you can add a second field and set it's value based on whats in your
tracker field.


Hope this helps

Cheers
Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top