Home > Uncategorized > InfoPath Error: Reference to undeclared namespace prefix “dfs”

InfoPath Error: Reference to undeclared namespace prefix “dfs”

March 17th, 2010 Leave a comment Go to comments

Error:

If you are trying to get/set values using XPath on Secondary Data Source, you might get the error “Reference to undeclared namespace prefix: dfs”.

Cause:

When you are trying to use XPath expression on Secondary Data Source, you must have to declare the namespace that is going to be used in the code. By default, InfoPath does NOT add namespace for Secondary Data Source. You have to add it manually.

Resolution:

  1. Select the top most element of the Secondary Data Source, right click on it and go to Properties…
    secondary-property
  2. Now copy the namespace shown in the image below.
    secondary-namespace
  3. Now in “script.js” file, add the following line at the top where other namespace is defined.
    XDocument.DataObjects("UpdateListItems").DOM.setProperty("SelectionNamespaces",
     'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');

    Please note that “UpdateListItems” is the name of my Secondary Data Source. Replace it with your Secondary Data Source name. Also “dfs” namespace may differ for you so replace it with the namespace you got in Step 2.

Categories: Uncategorized Tags:
  1. jayaseelan
    April 29th, 2010 at 01:44 | #1

    how to find script.js file.

  2. April 29th, 2010 at 14:27 | #2

    @jayaseelan
    script.js file is for the InfoPath form with JScript programming language.
    Now you can go to Tools > Programming > Microsoft Script Editor and it will open up script.js file.
    If you don’t have Microsoft Script Editor option, you probably might not have VSTO installed. Please search on google how to install VSTO for InfoPath.

  1. No trackbacks yet.