How to find if/where Data Source field is used?

M

Martin Eckart

Hi guys,

I have created form with quite many data source fields. Now it is about to
make the form ready for deployment. I have found a few data source fields
which I am not sure if they are used in the final version.
Is there a way how to find out if and where a specific data source field is
used within my form?

Thanks,
Martin
 
S

Shiraz Cupala

InfoPath doesn't provide a way to do this out of the box. However, it is
possible to search for this manually. There are a few tricks to this though
and it does involve reading XSL code. Not for the faint of heart but I will
try to explain nonetheless.

At first thought you could:
1) Open the form template Designer.
2) Select File::Extract form files and save the template to a folder.
3) Write down the names of the data source fields you want to search for.
4) Open each *.xsl file in Notepad and do Find for each field name.

Pitfall #1
However, this has the pitfall of matching against text labels in the form
(e.g. "City") so you wouldn't be sure that the field is actually bound in the
form.

The way fields are actually bound into the form is through the xd:binding
attribute. For example a data source field called "city" might match as

xd:binding="my:city"

The "my:" part is called a prefix. Under the hood InfoPath uses prefixes to
keep track of which data source fields conform to which schemas. This is part
of the XML standard. The "my:" prefix is InfoPath's default if you create a
new blank form in InfoPath.

If you search for any xd:binding instances in the *.xsl files you'll quickly
figure out what prefix your data source fields have. Then you can search
directly for those.

Pitfall #2:
Now, if for some reason your data source has some fields that have the same
name but in different parts of the data source this is a little trickier. You
need to be sure that you are finding the exact instance of that field.

This is trickier. If you just search on the field name (e.g. "my:city") but
that field appears under both an Employee group and a Manager group (for
example), then you might get one field but not the other.

This is where you need to read the code a little more closely. If the
fieldis not contained in a repeating group then it will likely be found in
something like xd:binding="my:employee/my:city". When you do your search you
need to pay attention to that closely to verify you found the right field.

If the field is in a repeating table or repeating section then it's
trickier. It may only show up as "my:city" but if you walk backwards in the
code you will see something like <xsl:for-each
select="my:group1/my:employee">. When you find that you then know the
"context" of the instance you found.

At this point you're really getting into the structure of the XSL code and
need to pay attention to where the for-each opens and closes as you walk the
code.

I hope this helps.
 

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