Calculations per repeating table row in VB.Net

M

Mark Parter

I'm "developing" an overtime claim form in InfoPath. In this form is a
Repeating Table. This table has the following fields:-

ClaimInstanceDate
TimeFrom
TimeTo
HoursWorked
HoursPaid
Reason

What I'm trying to do, is, calculate and populate the field HoursWorked with
the result of TimeTo - TimeFrom. I can do all the calculations OK in VB.Net,
I'm struggling to figure out how I know what that current 'Table' is so it
calculates and populates the correct fields.

I've tried using:-

Dim nodeClaimDate As IXMLDOMNode =
e.Site.selectSingleNode("../my:ClaimInstanceDate")
Dim nodeTimeFrom As IXMLDOMNode = e.Site.selectSingleNode("../my:TimeFrom")
Dim nodeTimeTo As IXMLDOMNode = e.Site.selectSingleNode("../my:TimeTo")
Dim nodeHoursWorked As IXMLDOMNode =
e.Site.selectSingleNode("../my:HoursWorked")

But this doesn't work. UI'm fumbling about in the dark here and it's really
starting to annoy me. Especially the lack of resources on the Internet for
doing this in managed code (not rules or JScript).

Can anybody save me, please?

Thanks.
 
M

Mark Parter

Thanks for the reply Michelle. I had a funny feeling somebody would reply
with a link from that site. Unfortunately, the example there is no use for me
and is in JScript and not managed code (VB.Net or C#).

Thanks anyway.

Anybody else?
 
M

Mark Parter

Well, using

Dim nodeTimeFrom As IXMLDOMNode = e.Site.selectSingleNode("../my:TimeFrom")

works OK if you only want to retrieve one value, but as I'm retrieving 4 at
once, like so;

Dim nodeClaimDate As IXMLDOMNode =
e.Site.selectSingleNode("../my:ClaimInstanceDate")
Dim nodeTimeFrom As IXMLDOMNode = e.Site.selectSingleNode("../my:TimeFrom")
Dim nodeTimeTo As IXMLDOMNode = e.Site.selectSingleNode("../my:TimeTo")
Dim nodeHoursWorked As IXMLDOMNode =
e.Site.selectSingleNode("../my:HoursWorked")

Only the ClaimInstanceDate is retrieved, all the other variables end up with
no data :(

Thanks.
 
M

Michelle

When you step through the debugger look at the xml for both e.Site and
e.Source as Matthew described. The reason you may not be getting data for
the other three nodes is that they may not be contained in the e.Site XML
fragment.

Once you have the node reference to the ClaimInstanceDate (which you say
works) try traversing that node to get the other sibling values, such as:

But really, the best thing to do is look at the e.Site XML fragment you're
trying to work with in the debugger - that really will direct you much better
as to what kind of XPath you will need to write.

Michelle
 
M

Mark Parter

I've managed to get it working by creating a procedure to handle all the
calculations and then passing this procedure e.Site.parentNode.

Thanks.
 

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