I'm starting on some of my first InfoPath forms. I have a three drop down lists (Global Function
, Major Task
, and Subtask
) which need to query a SQL database and filter their data based on the selected value in the drop down list before it.
What I've Done So Far
I've already added Data Connections (for each of the tables & corresponding drop down list) which simply query the database for all the records in a table. Each connection is set to "Store a copy of the data in the form template" for Offline Mode.
Then in the Drop-Down List Box Properties, I've set the List box choices to "Get choices from an external data source" and setup the Entries field to select the columns for the appropriate table / drop-down list combination.
However, when I add a filter to the data and try to preview the form, the data in the "cascaded" drop down list never changes. It still has ALL of the records.
So then I tried to add a new Rule for one of the cascading drop downs. For example, I created a new rule for the Major Task
drop down and set it up as follows:
Global Function is not blank
Action
I don't see anywhere in the Rule / Action to filter the data.
EDIT I've just tried a new Data Connection which has all three tables (GlobalFunctions
, MajorTasks
, and Subtasks
) that correctly setup the relations (i.e. GlobalFunctions.Id = MajorTasks.GlobalFunction). Then I set the drop down lists' data source to this new connection. However, this too does not filter the data at all. Their entries and values are as follows:
/dfs:myFields/dfs:dataFields/d_1:GlobalFunctions
<None>
@Id
@Summary
/dfs:myFields/dfs:dataFields/d_1:GlobalFunctions/d_1:MajorTasks
GlobalFunction = Id
@Id
@Summary
/dfs:myFields/dfs:dataFields/d_1:GlobalFunctions/d_1:MajorTasks/d_1:SubTasks
MajorTask = Id
@Id
@Summary
Restrictions
Question
How do I implement multiple cascading drop-down lists in InfoPath 2010 with data connections to a MS SQL Database that can work in the browser and using InfoPath Filler (the latter of which may not have a connection to the database).
SQL Tables
Here's what the tables look like:
CREATE TABLE GlobalFunctions (
Id SMALLINT NOT NULL IDENTITY(1,1),
Summary varchar(MAX) NOT NULL UNIQUE,
PRIMARY KEY (Id)
);
CREATE TABLE MajorTasks (
Id SMALLINT NOT NULL IDENTITY(1,1),
Summary varchar(MAX) NOT NULL UNIQUE,
GlobalFunction SMALLINT NOT NULL,
PRIMARY KEY (Id),
FOREIGN KEY (GlobalFunction) REFERENCES GlobalFunctions(Id)
);
CREATE TABLE SubTasks (
Id SMALLINT NOT NULL IDENTITY(1,1),
Summary varchar(MAX) NOT NULL UNIQUE,
MajorTask SMALLINT NOT NULL,
PRIMARY KEY (Id),
FOREIGN KEY (MajorTask) REFERENCES SubTasks(Id)
);
OK, I found my solution in this article.
Basically my problem was I was not selecting the correct value (the one that was actually selected) in the previous drop down list when filtering on the current drop down list. Instead, I was selected the value of the option based on the database data.
These are the steps I took to fix my problem (reproduced from the article in case it goes down):
MajorTasks
select :GlobalFunction
(the FK relationship to the Global Function table).