So Close (current funciton and repeating tables i think)

S

Shaun

Before I ask what I hope it my final question, I want to say thanks for all
the help. This is my first infopath project and it is a little ambitious for
a first attempt. I've gotten everything working with one exception. Here is
the problem, i was hoping someone could help me. I'm pretty sure I should be
using the current function somehow but i don't really know how.

I have a repeating table that has a nested repeating table inside of it. I
want to set the default value of a textbox inside this nested repeating table
to a value obtained via a function that operates on a secondary datasource. I
want to count all the rows in this seconday datasource only if a field in the
seconday datasource = a field in this nested repeating table. For some
reason, it doesn't seem to work using the point-click method of building a
default value; it just repeats the same value on every textbox.

Should I be using the current function somehow? I've read some other posts
on using the current function and i don't understand how to use it if i want
to count instances in a seconday datastore, filtered via a comparrison
between a value in the repeating table and the value in that secondary data
store.

Thanks again.
 
S

Shaun

just for further info. The XPATH of what i'm trying to do using the
point-click method is:

count(xdXDocument:GetDOM("Vehicles")/dfs:myFields/dfs:dataFields/d:Vehicles/d:radioVeh[@radioSystem
=
xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/d:comSystemList/d:Systems/@TOC_System])

and my version with my non-working usage of current is:
count(xdXDocument:GetDOM("Vehicles")/dfs:myFields/dfs:dataFields/d:Vehicles/d:radioVeh[@radioSystem = current()/my:TOC_System])

see, i think with the first version it is simply using the first instance in
the repeating table vs. the actual current one. My attempt at using the
current() function doesn't work but that's what i'm trying to do.
 
A

Adam Harding

Shaun

you will have to experiment moving further up the data tree after the equals
sign.

EG

count(xdXDocument:GetDOM("Vehicles")/dfs:myFields/dfs:dataFields/d:Vehicles/d:radioVeh[@radioSystem = current()/@TOC_System])

OR

count(xdXDocument:GetDOM("Vehicles")/dfs:myFields/dfs:dataFields/d:Vehicles/d:radioVeh[@radioSystem = current()/d:systems/TOC_System])

And so on

At one point it will work and I THINK it is around the /d:comSystemList bit
but it is all a bit hazy. ONE of them will suddenly work and it is amazing
when it does, looks VERY slick.


Cheers Adam
 
S

Shaun

This isn't working, I guess i'm in over my head but this has to easy and i'm
just missing something so let me try asking it a different way.

In my repeating table I have a value (../@TOC_System) and I want to count
the rows in a secondary datastore where the key = that value. When I try and
count off the secondary datastore I guess it tried to look at only the first
.../@TOC_System instead of the current rows ../@TOC_System. I've tried every
usage of the current() function that I can think of but I can't even get it
to return anything.

Adam Harding said:
Shaun

you will have to experiment moving further up the data tree after the equals
sign.

EG

count(xdXDocument:GetDOM("Vehicles")/dfs:myFields/dfs:dataFields/d:Vehicles/d:radioVeh[@radioSystem = current()/@TOC_System])

OR

count(xdXDocument:GetDOM("Vehicles")/dfs:myFields/dfs:dataFields/d:Vehicles/d:radioVeh[@radioSystem = current()/d:systems/TOC_System])

And so on

At one point it will work and I THINK it is around the /d:comSystemList bit
but it is all a bit hazy. ONE of them will suddenly work and it is amazing
when it does, looks VERY slick.


Cheers Adam

Shaun said:
just for further info. The XPATH of what i'm trying to do using the
point-click method is:

count(xdXDocument:GetDOM("Vehicles")/dfs:myFields/dfs:dataFields/d:Vehicles/d:radioVeh[@radioSystem
=
xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/d:comSystemList/d:Systems/@TOC_System])

and my version with my non-working usage of current is:
count(xdXDocument:GetDOM("Vehicles")/dfs:myFields/dfs:dataFields/d:Vehicles/d:radioVeh[@radioSystem = current()/my:TOC_System])

see, i think with the first version it is simply using the first instance in
the repeating table vs. the actual current one. My attempt at using the
current() function doesn't work but that's what i'm trying to do.
 
S

Shaun

Just to further help. I'm trying this xpath

count(xdXDocument:GetDOM("Vehicles")/dfs:myFields/dfs:dataFields/d:Vehicles/d:radioVeh[(../@BN_ID
= xdXDocument:get-DOM()/dfs:myFields/dfs:queryFields/q:Systems/@BN_ID) and
(current()/dfs:myFields/dfs:dataFields/d:comSystemList/d:Systems/@TOC_System
= @radioSystem)])

and i've moved that current() all the way down with no results, always
completely blank. I tried to do some debuging and tried to set the field to
(current()/dfs:myFields/dfs:dataFields/d:comSystemList/d:Systems/@TOC_System)
and removing each of the folders one-by-one and it will never display
anything.

The original point-click query was:
count(xdXDocument:GetDOM("Vehicles")/dfs:myFields/dfs:dataFields/d:Vehicles/d:radioVeh[(../@BN_ID
= xdXDocument:get-DOM()/dfs:myFields/dfs:queryFields/q:Systems/@BN_ID) and
(@radioSystem =
xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/d:comSystemList/d:Systems/@TOC_System)])

I know i'm close but I just can't get there.

Shaun
 
G

Greg Collins [InfoPath MVP]

current() doesn't work the way you are trying to use it.

It can be very difficult at time to understand where current() actually places you in your XPath hierrarchy. But to use it as a root node, as in your first example, is just an invalid use.

I know this isn't fun, but you'll need to identify just which node in your schema structure that current() represents in your scenario. Then you build your XPath from current() in terms of that actual node it represents.

So, if current() represented d:Systems then all you would need is current()/@TOC_System.

Make sense?
 
S

Shaun

Thank you for your help. I understand what you are saying. to try and debug,
I 'walked' the current down the tree but it was always blank. then I decided
to try and just get it to display where it was so I did a name(current()) and
it reported the name of the textboz the function was in, not even close to
what I was shooting for. 3hen I tried getting to the 'parent' node but based
on the xpath examples I could find that wasn't working either. I just don't
understand why when I just do a ../@Toc_system it gets it right but then when
I try and use that in a filter on a secondary datastore it just refers to the
first entry. how can I refer to the current repeated row? thanks for your
patience; i'm learning quite a bit.
 

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