SID-01998: Using CALC inside a SEARCH
| Status: |
Answered |
TWiki version: |
4.2.1 |
Perl version: |
5.8.8 |
| Category: |
CategorySearch |
Server OS: |
Linux |
Last update: |
10 years ago |
My objective is to use
%CALC to get the value of the previous cell in a table (see below) and use it to search for a topic and display its form values.
Column 1 (Sx0123) is a topic with a Form containing
LastName and
FirstName fields.
What am I missing? Thanks.
--
Bob Mellinger - 2014-12-04
Discussion and Answer
The problem is that
%CALC is not evaluated inside-out & left-to-right like other variables. The
%CALCULATE has the proper evaluation order, but it does not support references to table cells. This is documented in
SpreadSheetPlugin.
In your case you need to delay the
%SEARCH so that it evaluates after
%CALC. Untested:
%CALC{$NOP(%)SEARCH{ "$T(R$ROW():C$COLUMN(-1))" scope="topic" nosearch="on" nototal="on" expandvariables="on" format="$formfield(LastName), $formfield(FirstName)" }$NOP(%)}%
In your case it might be faster to use
%FORMFIELD instead of
%SEARCH. Untested:
%CALC{$SET(topic, $T(R$ROW():C$COLUMN(-1)))$NOP(%)FORMFIELD{ "LastName" topic="$GET(topic)" }$NOP(%), $NOP(%)FORMFIELD{ "FirstName" topic="$GET(topic)" }$NOP(%)}%
Consider hiding the formula in a FIRSTLASTNAME preferences setting so that you can simply write:
--
Peter Thoeny - 2014-12-05
Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the
TWiki consultants if you need timely help. We invite you to
get involved with the community, it is more likely you get community support if you support the open source project!
--
Peter Thoeny - 2015-12-03
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.