Using the XDocument.DOM in Infopath

I

ikidd

I have created a repeating section that contains a text field that is
the result of a vbScript function that calculates the difference in 2
time fields in the repeating section. I've done this because I can't
find such a function built into Infopath.

I'm using the

XDocument.DOM.selectSingleNode("/my:Digital_SO_Entry/my:grpTimeEntry/my:txtEntryOTBillHours").text
= intDateDiff

function to locate the text box and write the value to it.
Unfortunately, this only works for the first section, and subsequent
sections will read and write from the first set of controls only.

Is there a way to pass in the current node of the repeating section or
locate it using some property of the control that triggers the function
so I can properly locate the instance of the controls I want to read
from and write to?

If someone can even just point me to a tutorial or examples in how to
navigate the XML node structure from within Infopath scripting, I
should be able to figure it out.

I can post my code if you need to see what is happening.

TIA
 
B

Ben Walters

Hey ikidd
The problem your experiencing is due to the fact that your using a Select
single node statement

XDocument.DOM.selectSingleNode("/my:Digital_SO_Entry/my:grpTimeEntry/my:txtEntryOTBillHours").text = intDateDiff

The xpath expression passed in will match on the first node it finds and
return that.
What you will need to do is use the selectNodes method to return a list of
nodes then loop through that check the code provided

C#
IXMLDOMNodeList MyNodes =
e.XDocument.DOM.selectNodes("/my:Digital_SO_Entry/my:grpTimeEntry")

for each IXMLDOMNode BillHours in MyNodes
{
BillHours.SelectSingleNode("//my:txtEntryOTBillHours").text = intDateDiff
}

Hope this helps

Ben
 
I

ikidd

I noticed that I could pull the nodes collection, but I couldn't find a
way to determine the index of the current entry in the Entries group
that was the entry point into the script. I have to figure it is a
property of the eventobj object but I can't figure out how to use it to
determine the current node and read and write relative to that.
 
I

ikidd

That worked great. I see the code passes the eventobj.source to the
functions, and that's the start point I needed. I also needed the DOM
handling function parentnode for the eventobj.source. I'm definitely
going to look on your site for other info.

Ben, thanks for the pointer to the SDK. I didn't want to get out of
VBscript because that complicates the deployment a fair bit, but I
definitely appreciate the help, both of you.
 
S

S.Y.M. Wong-A-Ton

No worries. Glad to help.
---
S.Y.M. Wong-A-Ton


ikidd said:
That worked great. I see the code passes the eventobj.source to the
functions, and that's the start point I needed. I also needed the DOM
handling function parentnode for the eventobj.source. I'm definitely
going to look on your site for other info.

Ben, thanks for the pointer to the SDK. I didn't want to get out of
VBscript because that complicates the deployment a fair bit, but I
definitely appreciate the help, both of you.
 

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