Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / October 2007

Tip: Looking for answers? Try searching our database.

Secondary Data Source selectNodes fails

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JustinDevine - 27 Sep 2007 18:08 GMT
I have a secondary data source I want to manipulate in JScript.  I
have read just about every post on this subject, including the common
namespace issues, which I don't believe is an issue here.

First I would like to understand why Example 3 works when I use it on
a local data source (the result is the printing of all fields of a row
in a single dialog box) however when I try the same operation in
Example 2 it returns a blank dialog box.  However if I use the code in
Example 1 and focus on one field I get that field returned for all
cases that pass the filter, one field her dialog box.

Second, my goal is to simply concatenate the Last_Name and First_Name
field for each row in the set returned from the "Workshop History"
DataObject (SharePoint list).  If you know a much simpler way to do
this... and I am sure there is, please help as I have been working on
this for 2 days :-(.  Thanks!

EXAMPLE 1: This code works

function CTRL194_5::OnClick(eventObj)
{
    workshop = XDocument.DOM.selectSingleNode("/my:myFields/
my:Workshop").text
    chosenDate = XDocument.DOM.selectSingleNode("/my:myFields/
my:ChosenDate").text
    history = XDocument.DataObjects("Workshop History").DOM
    history.setProperty("SelectionNamespaces",'xmlns:dfs="http://
schemas.microsoft.com/office/infopath/2003/dataFormSolution"
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/
dataFormSolution"' );
    selectedHistory = history.selectNodes("/dfs:myFields/dfs:dataFields/
dfs:Workshop_History/Last_Name[../@Workshop = '" + workshop +"' and ../
@Workshop_Date = '" + chosenDate +"']")

    var node;
    while( ( node = selectedHistory.nextNode()) != null)
    {
        XDocument.UI.Alert(node.text)
    }

EXAMPLE 2:  (This code does not work)

function CTRL194_5::OnClick(eventObj)
{
    workshop = XDocument.DOM.selectSingleNode("/my:myFields/
my:Workshop").text
    chosenDate = XDocument.DOM.selectSingleNode("/my:myFields/
my:ChosenDate").text
    history = XDocument.DataObjects("Workshop History").DOM
    history.setProperty("SelectionNamespaces",'xmlns:dfs="http://
schemas.microsoft.com/office/infopath/2003/dataFormSolution"
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/
dataFormSolution"' );
    selectedHistory = history.selectNodes("/dfs:myFields/dfs:dataFields/
dfs:Workshop_History[@Workshop = '" + workshop +"' and @Workshop_Date
= '" + chosenDate +"']")

    var node;
    while( ( node = selectedHistory.nextNode()) != null)
    {
        XDocument.UI.Alert(node.text)
    }

EXAMPLE 3:
function doSubmit(eventObj) {
    var nodeList = XDocument.DOM.selectNodes("my:myFields/
my:AttendGroup")
    var node

    while( ( node = nodeList.nextNode()) != null)
    {
    XDocument.UI.Alert(node.text)
    }
Shiva (GGK Tech) - 01 Oct 2007 08:52 GMT
Hi,

First thing you have to use try and catch statements then we have a chance
to know what the error is and what type of error we are getting?

Did you check you are getting the ‘history’ document element? One more are
you can try for first xpath as below to get selected nodes:

selectedHistory = history.selectNodes("/dfs:myFields/dfs:dataFields/
dfs:Workshop_History[@Workshop = '" + workshop +"' and ../
@Workshop_Date = '" + chosenDate +"']/Last_Name ")

If above once also not working then you can try to give full XPath for
‘workshop’ and ‘chosenDate’ fields. For this field you didn’t specify any
prefix? What type of fields it is?

Hope this helps you

Signature

Shiva
http://www.ggktech.com

> I have a secondary data source I want to manipulate in JScript.  I
> have read just about every post on this subject, including the common
[quoted text clipped - 69 lines]
>     XDocument.UI.Alert(node.text)
>     }
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.