Repeatable Table - Only first line is filed out

R

rg66

Hello,

I am writing in VBScript.

I have a script which updates a field in the repeatable Table, which I
do like this

Set nodeFaktor =
XDocument.DOM.selectSingleNode("/my:meineFelder/my:reisediäten/my:exp_land/my:dsatz_faktor")
faktorwert = 2
nodeFaktor.text = faktorwert

When I go into the view form and I fill out all the fields, the field
dsatz_faktor receives the value 2. Which is what I want.

If i add now a second line, the field dsatz_faktor is not filled out.

Can some one tell me why this is not happening.

Thank you for any help!!

Robert
 
A

Adam Harding

Hi Robert

I have had this problem when not using code and solved it using the
current() function. That tells the form that the action you are looking to
perform is to be on every row that is current.

Or you can simply set the default value of the field dsatz_faktor to 2 in
the form and use rules to modify it depending on conditions.

I hope i understoodf you correctly and this helps

Cheers Adam
 
S

S.Y.M. Wong-A-Ton

Your code is not specifying which child node in the repeating group you want
to set the value on, so it automatically grabs the first child in the group.
You will either have to traverse the child nodes and find the child node
whose value you want to set or use a static XPath filter like [1] or [2] or
[position()=last()] on the group to specify the child node to use. Check out
http://www.w3.org/TR/xpath for more information on how to use XPath.
 
R

rg66

Adam,

thank you!

because the result I am calculating is enbedded in a function, I can
not use the Current() function. Tried it out and it did not work.

Thanks for the help!! very appreciated!

Robert
 
N

news.microsoft.com

I am trying to do the same thing as Robert, now stuck with XPath. As a
beginner I must admit that I can't find the correct syntax. Here's what I
try to do in Infopath:

I have a repeatable table. One column is start time, the second is end time,
and a third column total time. The idea is that when start and end time are
entered the total time should be calculated for each row. Now, as a
repeatable table, there can be more than only one row containing
start/end/total time.

I'm trying to do this with JScript:

function berechneStunden(){
var xmlFromTimes =
XDocument.DOM.selectNodes("//*[starts-with(name(),'my:Zeiten')]");
var xmlFromTime;
while (xmlFromTime = xmlFromTimes.nextNode()){

var time_from = xmlFromTime.firstChild.text;
XDocument.UI.Alert(time_from);

}

}

The loop seems to work ok, it travels through each row, the group is called
"my:Zeiten". However, how do I grab the single fields in each row from here?
xmlFromTime.firstChild.text gives me an empty value ... The three field are
named "zeit_von", "zeit_bis" and "zeit_summe".

Any help appreciated :)
Bernhard


S.Y.M. Wong-A-Ton said:
Your code is not specifying which child node in the repeating group you
want
to set the value on, so it automatically grabs the first child in the
group.
You will either have to traverse the child nodes and find the child node
whose value you want to set or use a static XPath filter like [1] or [2]
or
[position()=last()] on the group to specify the child node to use. Check
out
http://www.w3.org/TR/xpath for more information on how to use XPath.
---
S.Y.M. Wong-A-Ton


rg66 said:
Hello,

I am writing in VBScript.

I have a script which updates a field in the repeatable Table, which I
do like this

Set nodeFaktor =
XDocument.DOM.selectSingleNode("/my:meineFelder/my:reisediäten/my:exp_land/my:dsatz_faktor")
faktorwert = 2
nodeFaktor.text = faktorwert

When I go into the view form and I fill out all the fields, the field
dsatz_faktor receives the value 2. Which is what I want.

If i add now a second line, the field dsatz_faktor is not filled out.

Can some one tell me why this is not happening.

Thank you for any help!!

Robert
 
B

Bernhard Straub

oh - forgot to configure my Outlook Express correctly - hope that this time
my name appears in the "from" column...

Sorry
Bernhard
 
S

S.Y.M. Wong-A-Ton

Have you already taken a look at these 2 links?

http://enterprise-solutions.swits.net/infopath/adding-time-calculating-differences.htm
http://enterprise-solutions.swits.net/infopath/time-calculations-using-rules.htm

Your scenario sounds simple enough to use either rules or the calculation I
proposed in the first link. Check it out and see if that's what you're
looking for. I think Robert also had dates in his scenario, which makes
things slightly more complicated.
---
S.Y.M. Wong-A-Ton


news.microsoft.com said:
I am trying to do the same thing as Robert, now stuck with XPath. As a
beginner I must admit that I can't find the correct syntax. Here's what I
try to do in Infopath:

I have a repeatable table. One column is start time, the second is end time,
and a third column total time. The idea is that when start and end time are
entered the total time should be calculated for each row. Now, as a
repeatable table, there can be more than only one row containing
start/end/total time.

I'm trying to do this with JScript:

function berechneStunden(){
var xmlFromTimes =
XDocument.DOM.selectNodes("//*[starts-with(name(),'my:Zeiten')]");
var xmlFromTime;
while (xmlFromTime = xmlFromTimes.nextNode()){

var time_from = xmlFromTime.firstChild.text;
XDocument.UI.Alert(time_from);

}

}

The loop seems to work ok, it travels through each row, the group is called
"my:Zeiten". However, how do I grab the single fields in each row from here?
xmlFromTime.firstChild.text gives me an empty value ... The three field are
named "zeit_von", "zeit_bis" and "zeit_summe".

Any help appreciated :)
Bernhard


S.Y.M. Wong-A-Ton said:
Your code is not specifying which child node in the repeating group you
want
to set the value on, so it automatically grabs the first child in the
group.
You will either have to traverse the child nodes and find the child node
whose value you want to set or use a static XPath filter like [1] or [2]
or
[position()=last()] on the group to specify the child node to use. Check
out
http://www.w3.org/TR/xpath for more information on how to use XPath.
---
S.Y.M. Wong-A-Ton


rg66 said:
Hello,

I am writing in VBScript.

I have a script which updates a field in the repeatable Table, which I
do like this

Set nodeFaktor =
XDocument.DOM.selectSingleNode("/my:meineFelder/my:reisediäten/my:exp_land/my:dsatz_faktor")
faktorwert = 2
nodeFaktor.text = faktorwert

When I go into the view form and I fill out all the fields, the field
dsatz_faktor receives the value 2. Which is what I want.

If i add now a second line, the field dsatz_faktor is not filled out.

Can some one tell me why this is not happening.

Thank you for any help!!

Robert
 
B

Bernhard Straub

Perfect! Exactly what I needed. Thanks for your help and the links!

Best regards - Bernhard


S.Y.M. Wong-A-Ton said:
Have you already taken a look at these 2 links?

http://enterprise-solutions.swits.net/infopath/adding-time-calculating-differences.htm
http://enterprise-solutions.swits.net/infopath/time-calculations-using-rules.htm

Your scenario sounds simple enough to use either rules or the calculation
I
proposed in the first link. Check it out and see if that's what you're
looking for. I think Robert also had dates in his scenario, which makes
things slightly more complicated.
---
S.Y.M. Wong-A-Ton


news.microsoft.com said:
I am trying to do the same thing as Robert, now stuck with XPath. As a
beginner I must admit that I can't find the correct syntax. Here's what I
try to do in Infopath:

I have a repeatable table. One column is start time, the second is end
time,
and a third column total time. The idea is that when start and end time
are
entered the total time should be calculated for each row. Now, as a
repeatable table, there can be more than only one row containing
start/end/total time.

I'm trying to do this with JScript:

function berechneStunden(){
var xmlFromTimes =
XDocument.DOM.selectNodes("//*[starts-with(name(),'my:Zeiten')]");
var xmlFromTime;
while (xmlFromTime = xmlFromTimes.nextNode()){

var time_from = xmlFromTime.firstChild.text;
XDocument.UI.Alert(time_from);

}

}

The loop seems to work ok, it travels through each row, the group is
called
"my:Zeiten". However, how do I grab the single fields in each row from
here?
xmlFromTime.firstChild.text gives me an empty value ... The three field
are
named "zeit_von", "zeit_bis" and "zeit_summe".

Any help appreciated :)
Bernhard


message
Your code is not specifying which child node in the repeating group you
want
to set the value on, so it automatically grabs the first child in the
group.
You will either have to traverse the child nodes and find the child
node
whose value you want to set or use a static XPath filter like [1] or
[2]
or
[position()=last()] on the group to specify the child node to use.
Check
out
http://www.w3.org/TR/xpath for more information on how to use XPath.
---
S.Y.M. Wong-A-Ton


:

Hello,

I am writing in VBScript.

I have a script which updates a field in the repeatable Table, which I
do like this

Set nodeFaktor =
XDocument.DOM.selectSingleNode("/my:meineFelder/my:reisediäten/my:exp_land/my:dsatz_faktor")
faktorwert = 2
nodeFaktor.text = faktorwert

When I go into the view form and I fill out all the fields, the field
dsatz_faktor receives the value 2. Which is what I want.

If i add now a second line, the field dsatz_faktor is not filled out.

Can some one tell me why this is not happening.

Thank you for any help!!

Robert
 
S

S.Y.M. Wong-A-Ton

You're welcome!
---
S.Y.M. Wong-A-Ton


Bernhard Straub said:
Perfect! Exactly what I needed. Thanks for your help and the links!

Best regards - Bernhard


S.Y.M. Wong-A-Ton said:
Have you already taken a look at these 2 links?

http://enterprise-solutions.swits.net/infopath/adding-time-calculating-differences.htm
http://enterprise-solutions.swits.net/infopath/time-calculations-using-rules.htm

Your scenario sounds simple enough to use either rules or the calculation
I
proposed in the first link. Check it out and see if that's what you're
looking for. I think Robert also had dates in his scenario, which makes
things slightly more complicated.
---
S.Y.M. Wong-A-Ton


news.microsoft.com said:
I am trying to do the same thing as Robert, now stuck with XPath. As a
beginner I must admit that I can't find the correct syntax. Here's what I
try to do in Infopath:

I have a repeatable table. One column is start time, the second is end
time,
and a third column total time. The idea is that when start and end time
are
entered the total time should be calculated for each row. Now, as a
repeatable table, there can be more than only one row containing
start/end/total time.

I'm trying to do this with JScript:

function berechneStunden(){
var xmlFromTimes =
XDocument.DOM.selectNodes("//*[starts-with(name(),'my:Zeiten')]");
var xmlFromTime;
while (xmlFromTime = xmlFromTimes.nextNode()){

var time_from = xmlFromTime.firstChild.text;
XDocument.UI.Alert(time_from);

}

}

The loop seems to work ok, it travels through each row, the group is
called
"my:Zeiten". However, how do I grab the single fields in each row from
here?
xmlFromTime.firstChild.text gives me an empty value ... The three field
are
named "zeit_von", "zeit_bis" and "zeit_summe".

Any help appreciated :)
Bernhard


message
Your code is not specifying which child node in the repeating group you
want
to set the value on, so it automatically grabs the first child in the
group.
You will either have to traverse the child nodes and find the child
node
whose value you want to set or use a static XPath filter like [1] or
[2]
or
[position()=last()] on the group to specify the child node to use.
Check
out
http://www.w3.org/TR/xpath for more information on how to use XPath.
---
S.Y.M. Wong-A-Ton


:

Hello,

I am writing in VBScript.

I have a script which updates a field in the repeatable Table, which I
do like this

Set nodeFaktor =
XDocument.DOM.selectSingleNode("/my:meineFelder/my:reisediäten/my:exp_land/my:dsatz_faktor")
faktorwert = 2
nodeFaktor.text = faktorwert

When I go into the view form and I fill out all the fields, the field
dsatz_faktor receives the value 2. Which is what I want.

If i add now a second line, the field dsatz_faktor is not filled out.

Can some one tell me why this is not happening.

Thank you for any help!!

Robert
 
R

Robert Grund

S.Y.M,

hope that is the correct way to address you! If I look at your
time-calculations-using-rules link, is it possible to make this also for
Date and Time?

I am currently a bit stuck, meaning very much stuck! I am also getting to
the point of stopping the infopath project, as there is no real
documentations for beginners using vbscript or jscript. Still looking for a
good tutorial, learning by doing with examples. Tried to look at some of
the examples within Infopath, but their code is all in jscript. I am more
oriented towards vbscript.

Also one more questions is there a chance to use if statements in Rules?
This would make life much easier if that is possible, also within formulars?
Any commenrts?

Robert

S.Y.M. Wong-A-Ton said:
Have you already taken a look at these 2 links?

http://enterprise-solutions.swits.net/infopath/adding-time-calculating-differences.htm
http://enterprise-solutions.swits.net/infopath/time-calculations-using-rules.htm

Your scenario sounds simple enough to use either rules or the calculation
I
proposed in the first link. Check it out and see if that's what you're
looking for. I think Robert also had dates in his scenario, which makes
things slightly more complicated.
---
S.Y.M. Wong-A-Ton


news.microsoft.com said:
I am trying to do the same thing as Robert, now stuck with XPath. As a
beginner I must admit that I can't find the correct syntax. Here's what I
try to do in Infopath:

I have a repeatable table. One column is start time, the second is end
time,
and a third column total time. The idea is that when start and end time
are
entered the total time should be calculated for each row. Now, as a
repeatable table, there can be more than only one row containing
start/end/total time.

I'm trying to do this with JScript:

function berechneStunden(){
var xmlFromTimes =
XDocument.DOM.selectNodes("//*[starts-with(name(),'my:Zeiten')]");
var xmlFromTime;
while (xmlFromTime = xmlFromTimes.nextNode()){

var time_from = xmlFromTime.firstChild.text;
XDocument.UI.Alert(time_from);

}

}

The loop seems to work ok, it travels through each row, the group is
called
"my:Zeiten". However, how do I grab the single fields in each row from
here?
xmlFromTime.firstChild.text gives me an empty value ... The three field
are
named "zeit_von", "zeit_bis" and "zeit_summe".

Any help appreciated :)
Bernhard


message
Your code is not specifying which child node in the repeating group you
want
to set the value on, so it automatically grabs the first child in the
group.
You will either have to traverse the child nodes and find the child
node
whose value you want to set or use a static XPath filter like [1] or
[2]
or
[position()=last()] on the group to specify the child node to use.
Check
out
http://www.w3.org/TR/xpath for more information on how to use XPath.
---
S.Y.M. Wong-A-Ton


:

Hello,

I am writing in VBScript.

I have a script which updates a field in the repeatable Table, which I
do like this

Set nodeFaktor =
XDocument.DOM.selectSingleNode("/my:meineFelder/my:reisediäten/my:exp_land/my:dsatz_faktor")
faktorwert = 2
nodeFaktor.text = faktorwert

When I go into the view form and I fill out all the fields, the field
dsatz_faktor receives the value 2. Which is what I want.

If i add now a second line, the field dsatz_faktor is not filled out.

Can some one tell me why this is not happening.

Thank you for any help!!

Robert
 
S

S.Y.M. Wong-A-Ton

I can feel your pain...

You can do alot with rules and filters in InfoPath, but using rules to do
date/time calculations can quickly get very complicated. You can stretch the
limits, but there comes a time that comprehension will become impossible;
then I'd suggest using code. :)

It might be possible to convert my rules solution to include dates; I would
have to look into this for you. If you can hold on till after the weekend,
I'll give you an answer on Monday (my time during the week is rather
limited). If you cannot wait, I can give you a few pointers to try converting
it yourself; just let me know.

If you are looking for JScript or VBScript documentation, you can go to
http://www.microsoft.com/scripting/
There are complete references listed there.

Using VBScript is no different in InfoPath than using it elsewhere. The only
thing with InfoPath is the introduction of XSD, XML, XSL, and XPath. There
things might get a little bit more challenging if you're not comfortable with
these technologies. I agree that there are little samples available for
VBScript and I'll keep this in mind next time I write a "recipe" that uses
code.

You can "simulate" if statements when using rules by setting conditions on
the rules. But again, things can quickly get complicated. I'm not aware that
you can use if statements in formulas; I don't think this is possible.

---
S.Y.M. Wong-A-Ton



Robert Grund said:
S.Y.M,

hope that is the correct way to address you! If I look at your
time-calculations-using-rules link, is it possible to make this also for
Date and Time?

I am currently a bit stuck, meaning very much stuck! I am also getting to
the point of stopping the infopath project, as there is no real
documentations for beginners using vbscript or jscript. Still looking for a
good tutorial, learning by doing with examples. Tried to look at some of
the examples within Infopath, but their code is all in jscript. I am more
oriented towards vbscript.

Also one more questions is there a chance to use if statements in Rules?
This would make life much easier if that is possible, also within formulars?
Any commenrts?

Robert

S.Y.M. Wong-A-Ton said:
Have you already taken a look at these 2 links?

http://enterprise-solutions.swits.net/infopath/adding-time-calculating-differences.htm
http://enterprise-solutions.swits.net/infopath/time-calculations-using-rules.htm

Your scenario sounds simple enough to use either rules or the calculation
I
proposed in the first link. Check it out and see if that's what you're
looking for. I think Robert also had dates in his scenario, which makes
things slightly more complicated.
---
S.Y.M. Wong-A-Ton


news.microsoft.com said:
I am trying to do the same thing as Robert, now stuck with XPath. As a
beginner I must admit that I can't find the correct syntax. Here's what I
try to do in Infopath:

I have a repeatable table. One column is start time, the second is end
time,
and a third column total time. The idea is that when start and end time
are
entered the total time should be calculated for each row. Now, as a
repeatable table, there can be more than only one row containing
start/end/total time.

I'm trying to do this with JScript:

function berechneStunden(){
var xmlFromTimes =
XDocument.DOM.selectNodes("//*[starts-with(name(),'my:Zeiten')]");
var xmlFromTime;
while (xmlFromTime = xmlFromTimes.nextNode()){

var time_from = xmlFromTime.firstChild.text;
XDocument.UI.Alert(time_from);

}

}

The loop seems to work ok, it travels through each row, the group is
called
"my:Zeiten". However, how do I grab the single fields in each row from
here?
xmlFromTime.firstChild.text gives me an empty value ... The three field
are
named "zeit_von", "zeit_bis" and "zeit_summe".

Any help appreciated :)
Bernhard


message
Your code is not specifying which child node in the repeating group you
want
to set the value on, so it automatically grabs the first child in the
group.
You will either have to traverse the child nodes and find the child
node
whose value you want to set or use a static XPath filter like [1] or
[2]
or
[position()=last()] on the group to specify the child node to use.
Check
out
http://www.w3.org/TR/xpath for more information on how to use XPath.
---
S.Y.M. Wong-A-Ton


:

Hello,

I am writing in VBScript.

I have a script which updates a field in the repeatable Table, which I
do like this

Set nodeFaktor =
XDocument.DOM.selectSingleNode("/my:meineFelder/my:reisediäten/my:exp_land/my:dsatz_faktor")
faktorwert = 2
nodeFaktor.text = faktorwert

When I go into the view form and I fill out all the fields, the field
dsatz_faktor receives the value 2. Which is what I want.

If i add now a second line, the field dsatz_faktor is not filled out.

Can some one tell me why this is not happening.

Thank you for any help!!

Robert
 
R

rg66

I can wait until Monday, to see how you have mastered the problem.

Will meanwhile look into te XSD,XSL and XPath.

Thank you for helping me and us out. Very appreciated.

Robert
 
S

S.Y.M. Wong-A-Ton

Robert,

I looked into converting the solution using rules to include dates, but must
report that it is really too complex to implement. You would not only have to
perform the calculations, but also take things like leap years and amount of
days per month into consideration. Not worth the time and effort, since you
can do the calculations much quicker using code.

To help you out a bit, I've written two new "recipes": One explaining the
basics of dates in InfoPath
(http://enterprise-solutions.swits.net/infopath/date-time-basics-infopath.htm)
and another one using VBScript to calculate the difference between two date
pickers
(http://enterprise-solutions.swits.net/infopath/datediff-vbscript-infopath.htm).

Next week I'll try converting the JScript time difference calculation
solution into a VBScript version including dates in the calculation.

Hope the links help.
 
R

Robert G

Thank you for trying and giving my an honest answer back. Will start coding
then and will look into your example.

Thanks again for helping out.

Robert
 
S

S.Y.M. Wong-A-Ton

You're welcome.

The sample only does the calculations for dates, but if you have a "Date and
time" field on your form, you can parse out the hours and minutes using the
Mid() VBScript function, calculate the total amount of minutes since midnight
for each time (HH*60 + MM), and then subtract the total minutes of the
startTime from the endTime to get the total amount of minutes elapsed. Once
you have this, you can just add the result to the datediff calculation that
returns minutes between two dates to get your total amount of minutes between
two dates and times.

If you get stuck, let me know. I regret not having more time to get a
complete solution online for 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