Sign in
MSDN Blogs
Microsoft Blog Images
More ...
Microsoft InfoPath 2010
The official blog of the Microsoft InfoPath team
Common Tasks
Blog Home
Subscribe via RSS
RSS for comments
RSS for posts
Atom
recent posts
One-to-Many Relationships on Database Connections
Posted
over 7 years ago
by
infopath1
Enforcing unique values in a repeating list
Posted
over 7 years ago
by
infopath1
Tags
5 for forms
Academy Live
Beta
Browser Forms
Community
Controls
Cool Forms
Data Connections
Developer
Formulas and XPath
InfoPath 2010
InfoPath Form Web Part
Layout
Outlook
Picture button
Rapid Development
Sandboxed Solutions
SharePoint
SharePoint List
SharePoint Lists
Talks
Technical Preview
VSTA
Web Part
Writing Code
General
Office Online
Support Center
Office Developer Center
InfoPath Dev
Office Blogs
Microsoft Access
Microsoft Excel
Microsoft OneNote
Microsoft Outlook
Microsoft PowerPoint
Microsoft Project
Microsoft Publisher
Microsoft SharePoint
Microsoft SharePoint Designer
Microsoft SharePoint Workspace
Microsoft Visio
Microsoft Word
Office 2010 Engineering
Office Extensibility
Office Global Experience
Office Interoperability
Office Math
Office Natural Language Team
Office Sustained Engineering
Office Web Applications
Performance Point
Archives
Archives
April 2011
(1)
July 2010
(3)
June 2010
(3)
May 2010
(7)
April 2010
(12)
March 2010
(8)
February 2010
(8)
January 2010
(8)
December 2009
(3)
November 2009
(2)
October 2009
(3)
August 2009
(3)
July 2009
(3)
February 2009
(1)
October 2008
(1)
September 2008
(2)
August 2008
(1)
July 2008
(1)
June 2008
(5)
May 2008
(1)
April 2008
(1)
July 2007
(1)
May 2007
(2)
April 2007
(1)
March 2007
(11)
February 2007
(14)
January 2007
(13)
December 2006
(10)
November 2006
(14)
October 2006
(13)
September 2006
(3)
August 2006
(2)
July 2006
(8)
June 2006
(11)
May 2006
(8)
April 2006
(7)
March 2006
(2)
February 2006
(1)
December 2005
(1)
November 2005
(1)
August 2005
(1)
July 2005
(1)
June 2005
(3)
April 2005
(3)
March 2005
(2)
February 2005
(4)
January 2005
(2)
December 2004
(4)
November 2004
(8)
October 2004
(8)
September 2004
(10)
August 2004
(7)
July 2004
(2)
June 2004
(5)
May 2004
(12)
April 2004
(12)
March 2004
(16)
August, 2006
MSDN Blogs
>
Microsoft InfoPath 2010
>
August, 2006
Subscribe via RSS
Sort by:
Most Recent
|
Most Views
|
Most Comments
Excerpt View
|
Full Post View
Microsoft InfoPath 2010
One-to-Many Relationships on Database Connections
Posted
over 7 years ago
by
infopath1
9
Comments
There have been a few questions about how the main database submit data connection works with related tables. This is an FYI to clear up some of those issues, as I don't think this information ever made it public!
At least one of the relationships for every pair of related tables must include the left-hand table's
primary key
(PK) (where A is the left-hand table in "A relates to B on A.ID, B.ID"). Without this stipulation, there may be many records in table A that map to one record in table B along the defined relationship.
Note also that
unique indexes
and
unique constraints
allow nulls, so the primary key must be used in at least one relationship (they don't allow nulls). Basically, InfoPath enumerates the records to be updated according to the primary key. This way, the data inserted into the database is well-defined.
What that boils down to is this:
Sufficient relationships
:
PK --> Non-unique, Unique, or PK
Insufficient relationships
(assuming a sufficient relationship hasn't already been defined):
Non-Unique --> Non-unique, Unique, or PK
Unique --> Non-unique, Unique, or PK
Once you've defined one sufficient relationship (as listed above), then you can define any other additional relationships that you want (they don't have to follow my rules listed above).
- Forrest
Software Development Engineer in Test
Microsoft InfoPath 2010
Enforcing unique values in a repeating list
Posted
over 7 years ago
by
infopath1
1
Comments
Have you ever created a form which allows the user to choose items from a list and you wanted to make sure the user doesn't choose the same item twice? If you've got InfoPath 2007 you can use the
new Multi Select List Box
, but if you've got InfoPath 2003, you're still in luck, this blog entry is for you!
Note: You should be familiar with XPath expressions before preceding.
Let's start with a repeating table with a dropdown control bound to a secondary data source.
There are a few choices when it comes to enforcing unique values selected by the user:
Only show values that have not already been selected by the user.
Show a validation error when the user selects something which has already been selected.
Write code using the Changing event.
This blog entry will cover both options 1 and 2.
Option 1 - Only show values that have not already been selected by the user
Only showing certain values implies that a filter is being applied to the dropdown. To apply a filter, click the
Filter Data…
button when selecting the entries for the dropdown to show the condition builder. Unfortunately, there is no UI in the condition builder to build an expression that means "don't show anything that is already in the list". Thus, we'll have to construct this manually by selecting
The Expression
.
You might be tempted to put the following expression:
. != xdXDocument:get-DOM()/my:myFields/my:items/my:item/my:product
This will return true if any one value from the list matches the current value. In other words, this condition will always return true if there are two entries in the list which are different. (
Definitely
n
ot what we are looking for
)
The correct condition is a slight adjustment to the former expression:
not(. = xdXDocument:get-DOM()/my:myFields/my:items/my:item/my:product)
This will only return true if none of the values from the list matches the current value. In other words, only values that are not in the list will be displayed.
Preview the form and you will see that the dropdown only lists the products that have not already been selected.
Option 2 - Show a validation error when the user selects something which has already been selected
The only way this will work properly is if we add a hidden calculated field along with the product selection.
(The reason for this is a bit too complex to explain here, so it'll have to wait for another time.)
The formula for the unique field is the following:
not(../my:product = (../preceding-sibling::my:item | ../following-sibling::my:item)/my:product)
This will set Unique to true if and only if the product isn't already selected preceding or following the current item.
The next and final step is to use data validation on the dropdown to show an error.
Preview the form and you will see that the dropdown will show a validation error if the items are not unique.
- Gary
Software Development Engineer
Page 1 of 1 (2 items)