SID-00824: IF within SEARCH within FOREACH
| Status: |
Answered |
TWiki version: |
4.2.4 |
Perl version: |
|
| Category: |
CategoryPlugins |
Server OS: |
|
Last update: |
16 years ago |
Requirement:
for each X:
search for topics where a specified form field has value X
for each hit, check a second form field for whether it contains Yes (or No)
We tried
%FOREACH{"release" in="8, 19"}%
---++ $release
$percntSEARCH{
topic="Projects20.*" type="regex" nonoise="off"
search="META:FIELD.*?ReleaseNo.*?value=\"$release\""
format="[$formfield(ProjectName) $percntCALC{ $IF($EXACT($formfield(DevStartDateDone), Yes), - DONE,) }$percnt $n "}$percnt
%NEXT{"release"}%
But the
$IF($EXACT... returns false every time.
When I changed this code:
$percntCALC{ $IF($EXACT($formfield(DevStartDateDone), Yes), - DONE,) }$percnt
to
$percntCALC{ $IF($EXACT($formfield(DevStartDateDone), Yes), - DONE, $formfield(DevStartDateDone)) }$percnt
The "false" condition printed "Yes".
Is
$formfield(...) somehow not being evaluated inside the
$EXACT ?
Am I missing something obvious?
--
VickiBrown - 2010-05-04
Discussion and Answer
ForEachPluginDev - the last comment I made.
It is probably because you have
SpreadSheetPlugin (SSP) evaluated before
ForEachPlugin (FEP), but also, the FEP has a line to remove the $percent, so when it does that (since you escaped both the SEARCH and the CALC), you end up with SEARCH and CALC, which as you may know, won't work, as the CALC needs to be escaped within the SEARCH. So, I added a line to my FEP, to convert $dollar also, and made my CALC $dollar$percentCALC, and put FEP on the front of the plugin list (or, at least before SSP), and it works.
--
AaronLWalker - 2010-05-07
See my response in
TWikibug:Item6449
, issue with unfortunate spec of
ForEachPlugin that has unintended side-effects.
--
PeterThoeny - 2010-05-08
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.