Kevin Akselrod’s Blog

Just another WordPress.com weblog

Ensuring repeating fields are not blank in InfoPath 2007

leave a comment »

A bit of exciting news before I get to the real post:  Since I’ve last posted, I’ve studied for and passed the CAPM exam.

Anyway,…

The Situation

I am creating a form to track the staffing process at my company.  I have an InfoPath 2007 form that has a repeating table.  This table has two fields in it:  a Candidate Name textbox and a Notes attachment.  I want to know when, say, the Notes field has been filled in for every candidate.  So, upon submit, I want to check if all of the Notes fields in the repeating table have been filled in/have attachments in them, and, if they have, I want to populate a value in another field, Date.

The Issue

So, I created a rule on the Submit button to set the Date field to today’s date if the Notes field is not blank:

rule1

(The rule checks if the Date field is blank to ensure that the Date field is only filled in the first time the Notes fields are set, not every time the form is submitted.)

This rule meets what I would imagine would make sense – and also what I’ve seen other posts telling me to do.  However, this rule exhibits some unexpected behavior.  Let’s look at a truth table for two instances of the repeating table:

tt_isNotBlank

If even one of the Notes fields is not blank, then “is not blank” evaluates to True.  This is not the behavior that I am looking for – I want only the last column to evaluate to true.  But for a repeating field, if “is not blank” is true for one of the individual fields, it evaluates to True for the repeating field.

The Solution

You will notice that the above behavior is reflected in “is blank” as well:

tt_isBlank

If “is blank” is true for one of the individual fields, “is blank” evaluates to True for the repeating field.  Luckily, this is to our advantage:

What we are looking for is the exact opposite of the behavior we notice in “is blank;” we want the first three columns to evaluate to False and only the last column to evaluate to True.  To do that, all we need to do is take the “not” of the “is blank” function:

tt_not_isBlank

This gives us the behavior that we are seeking.  In order to do this in InfoPath, we want to open the Condition for the Rule, set “Notes is blank,” then switch “Notes” to “The expression:”

isBlank

This will allow you to edit the expression directly.  Just put a “not()” around the expression, and you’re done!

expression


Thanks go to g-man and crew for posting how to not an expression in this thread on InfoPath Dev.

Notes1 X X
Notes2 X X
is not blank F T T T
Advertisement

Written by Kevin Akselrod

September 10, 2009 at 8:48 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.