How to loop through a repeating table's group data nodes using pro

V

Victor

Hi,

I have a scenario like this. I let user key in their equipment data in a
repeating table. The equipment data are IssueDate, Item, Category and
ReturnedDate. User can key in IssueDate, Item, Category in the repeating
table. But they can leave the ReturnedDate blank. They only fill in the
ReturnedDate when they return the equipments. There is also a field named
Status outside the repeating table to indicate the equipment's returned
status. If all the equipments in the repeating table have been
returned(meaning all the ReturnedDate must be filled) , the status will
change from 'Active' to 'Closed'.

I have already got the solution of this using Rules and Set Condition in
the group's data nodes. Now i also want to update the Status when user delete
or add new rows by using custom code in the group's AfterChange event.

How do i loop through the group's data nodes to compare if all the nodes'
ReturnedDate have been filled in using programming codes?

I have been trying to use the groups' length like
var
nItem=XDocument.DOM.selectNodes("/my:myFields/my:Items/my:Item/my:ReturnedDate").length
and use a for loop to loop through the nodes. Actually, inside the group's
AfterChange event, it loops all the nodes. How do i loop through only
ReturnedDate nodes and compare the value of the ReturnedDate nodes if they
are blank or not blank using programming?

Can someone help me by providing me a few line sof codes?

Thanks.
 
Z

Zhang Haiguang

Please reference the following codes:
DOMNodeList field3NodeList = thisXDocument.DOM.selectNodes(
"/my:myFields/my:group1/my:group2/my:field3" );
foreach( DOMNode field3Node in field3NodeList )
{
if( field3Node.text.Length <= 0 )
{
thisXDocument.UI.Alert( "empty" );
}
}

InfoJet Service
InfoPath Web Form
http://www.infojetsoft.com
 
V

Victor

Hi,

Thank you for replying my query.Really appreciate that.

When i type d in this line of code, and run the program, it says
Expected ';' . I couldn't find the error. Please advice. Thanks.

DOMNodeList field3NodeList = thisXDocument.DOM.selectNodes(
"/my:myFields/my:group1/my:group2/my:field3" );
 
Z

Zhang Haiguang

Please put the two line
DOMNodeList field3NodeList = thisXDocument.DOM.selectNodes( and
"/my:myFields/my:group1/my:group2/my:field3" );
into one line.
the layout break the line ...
The content in the brackets should be in one line:
[DOMNodeList
field3NodeList=thisXDocument.DOM.selectNodes("/my:myFields/my:group1/my:group2/my:field3"
);]
 
V

Victor

Hi,
I have already followed your instruction to put the two lines into one
but still got that error message of Expected ';'. What is this DOMNodeList
means? Is it some kind of a class? Is it supported in Infopath 2003 sp2 coz i
am using Infopath 2003 SP2. I am not using Infopath 2007.
 
V

Victor

Hi zhang,

I managed to get my problem solved by using this:

var
oNodes=XDocument.DOM.selectNodes("//my:Items/my:Item/my:ReturnedDate");
var oStatus=XDocument.DOM.selectSingleNode("//my:Status");

if(oNodes)
{
while(oNode=oNodes.nextNode())
{
if(oNode.text=="")
{
nCount=nCount+1;
}

}

if(nCount > 0)
{
oStatus.text="Active";
}
else
{
oStatus.text="Closed";
}
}

Thanks a lot for your kind help!

Regards,
Victor


Victor said:
Hi,
I have already followed your instruction to put the two lines into one
but still got that error message of Expected ';'. What is this DOMNodeList
means? Is it some kind of a class? Is it supported in Infopath 2003 sp2 coz i
am using Infopath 2003 SP2. I am not using Infopath 2007.



Zhang Haiguang said:
Please put the two line
DOMNodeList field3NodeList = thisXDocument.DOM.selectNodes( and
"/my:myFields/my:group1/my:group2/my:field3" );
into one line.
the layout break the line ...
The content in the brackets should be in one line:
[DOMNodeList
field3NodeList=thisXDocument.DOM.selectNodes("/my:myFields/my:group1/my:group2/my:field3"
);]
 
Z

Zhang Haiguang

Hi Victor,

Thanks for your sharing, I thought you were using managed code wrongly in
the previous reply.
And there is an other way to do it in JScript:
var oNodes =
XDocument.DOM.selectNodes("/my:myFields/my:group1/my:group2/my:field3");
for( var index = 0; index < oNodes.length; index ++ )
{
XDocument.UI.Alert( oNodes[ index ].text );
}
DOMNodeList is supported by InfoPath 2003. Please reference the following
article:
http://msdn2.microsoft.com/en-US/li...op.infopath.semitrust.domnodelist(VS.80).aspx

Zhang
 

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