I have an XPath expression that returns true
or false
(NOT boolean, just strings in a text field).
I would like to set a condition on my target field so that its value varies if this XPath expression is true
v. false
. I know an InfoPath rule could easly change the field value.
My problem is that despite the XPath returning a string, I cannot seem to evaluate it with an InfoPath rule (EX: TargetField is blank / TargetField is not blank / TargetField is equal to true).
Specific Detail
I have 4 primary fields:
- Initial Date value (InitialDate)
- Repeating Date value (RepeaterDate - changes appended to the initial form)
- XPath expression field that captures prior entry in repeating date value field (listed after sample XML)
- XPath expression field to evaluate presence of Repeating Date (returns
true
orfalse
for present v. not present - listed after sample XML)
The XPath expression (#4 on the list) correctly returns 'true' or 'false'.
XML and XPath Expressions
<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution solutionVersion="1.0.0.10" productVersion="14.0.0" PIVersion="1.0.0.0" href="file:///C:\Documents%20and%20Settings\Chris\Local%20Settings\Application%20Data\Microsoft\InfoPath\Designer3\9016384cab6148f6\manifest.xsf" ?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?><my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-09-07T14:19:10" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us">
<my:InitialSection>
<my:InitialDate>2012-09-13</my:InitialDate>
</my:InitialSection>
<my:RepeaterSection>
<my:RepeaterGroup>
<my:RepeaterDate>2012-09-14</my:RepeaterDate>
</my:RepeaterGroup>
<my:RepeaterGroup>
<my:RepeaterDate>2012-09-17</my:RepeaterDate>
</my:RepeaterGroup>
<my:RepeaterGroup>
<my:RepeaterDate>2012-09-19</my:RepeaterDate>
</my:RepeaterGroup>
</my:RepeaterSection>
<my:DateEval>2012-09-19</my:DateEval>
<my:DateField xsi:nil="true"></my:DateField>
<my:DateEvalBool>true</my:DateEvalBool>
This example XML has several nodes containing revised dates. The DateEval field returns the last date in the repeating list using the following XPath Expression:
//my:RepeaterGroup[0=count(following-sibling::my:RepeaterGroup)]//my:RepeaterDate
This value is then evaluated for the presence of text using another XPath expression:
//my:RepeaterGroup[0=count(following-sibling::my:RepeaterGroup)]//my:RepeaterDate[(text())]
Again, this consistently returns true
or false
as you can see in the sample XML.
Initial Question
Why is it then that I cannot successfully evaluate this true
or false
value in a regular InfoPath 2010 field rule?
//my:RepeaterGroup[0=count(following-sibling::my:RepeaterGroup)]//my:RepeaterDate[(text())] | //my:InitialDate[text() and not(//my:RepeaterGroup[0=count(following-sibling::my:RepeaterGroup)]//my:RepeaterDate[(text())])]
It works well except that whenever I insert a new item in the repeating section this formula (despite being the default value) does not execute.