Question
I'm trying to perform a search based on the contents of a formfield within the page I am searching from. For example:
%SEARCH{"[T]opicClassification.*value\=.*[D]ocumentIdClass;[D]eploymentProject.*value\=.*%FORMIELD{Company Name}%;
[P]rojectDeliverable.*value\=.*Definition" web="Documents" scope="text" regex="on" nosearch="on" casesensitive="on"
order="modified" nototal="on" format="[[$web.$topic][$formfield(Document Name)]]"}%
where the attached form in the page includes an entry "Company Name", the contents of which I wish to use in the search.
The problem is my doesn't get expanded as its nested. I've tried to do with CALC but can't get it to build up correctly.
Is this possible?
Environment
--
StephenParkinson - 27 Apr 2005
Answer
Just a quick one, haven't tested - in the line above, there is a "F" missing in
FORMIELD?
--
SteffenPoulsen - 28 Apr 2005
OK - that's a typo sorry! with it spelt correctly doesn't work either!
--
StephenParkinson - 28 Apr 2005
Ahh, OK, I think I can follow you now. I think what you need is a nested search, where the "outer" search will find the contents of the formfield of the current topic, and from that construct a nested search using the found field contents as a parameter. Using a search is the only way to expand the form fields, even though it is a field in the current page, as far as I know.
FormattedSearch has examples on nested searches.
--
SteffenPoulsen - 28 Apr 2005
The reason why it does not work is that SEARCH is executed before FORMFIELD. You need a nested SEARCH as Steffen pointed out.
--
PeterThoeny - 30 Apr 2005
Thanks - that's done it now. Took me a bit of a while to get my head around the nested but got there in the end.
--
StephenParkinson - 02 May 2005
Would someone please detail exactly how to 'construct a nested search using the found field contents as a parameter' as suggested above?
--
JasonAment - 29 Aug 2005
... and add it to the
SearchPatternCookbook
--
JosMaccabiani - 29 Aug 2005
Try this out:
%SEARCH{ "%TOPIC%" scope="topic" nototal="on" nosearch="on" format="$percntSEARCH{ \"$formfield(Company Name);[T]opicClassification.*value\=.*[D]ocumentIdClass\" format=\" [[$dollarweb.$dollartopic][$dollarformfield(Document Name)]]\" nosearch=\"on\" nototal=\"on\" separator=\", \" }$nop%" }%
--
LynnwoodBrown - 30 Aug 2005
Yes, that looks like it will actually work for what I'm trying to do, but it's not exactly what I was thinking. I would like to get a search working that uses a formfield from the current form and matches it specifically to a related formfield on a different form. Your search allows me to use the field on the current form and search the whole topics for that pattern, but not equate it exactly to another formfield.
Here's what I have, perhaps I am missing something:
%SEARCH{ "%TOPIC%" scope="topic" nototal="on" nosearch="on" format="$percntSEARCH{\"[P]O Number.*value\=.*$formfield(PO Number)\" topic=\"ITPurchaseOrder*\" format=\"|[[$dollartopic][$dollarformfield(PO Number)]] |$dollarformfield(Date) | $dollarformfield(Supplier) |\" nosearch=\"on\" nototal=\"on\" separator=\", \" }$nop%" }%
Thank you for the help!
--
JasonAment - 31 Aug 2005
Jason - It looks to me like you've about got it. The only problem I see is the "separator" attribute at the end. Since the format you've defined is a table, you don't want a separator - so just delete that bit. Otherwise, it
looks to me like it should work and do what you're after.
One other comment: when you're pushing the envelop of SEARCH, as you are, it might be worth considering a more "robust" solution such as offered by
FormQueryPlugin. Good luck!
--
LynnwoodBrown - 31 Aug 2005
I'm pretty new on this, so my apologies if this questions seems trivial.
If I can say for example:
%SEARCH{"% TOPIC %" foo, foo, ...
% TOPIC % gets resolved as the name of the topic “before” .
Having being a TWiki variable, I would assume it would share the same rules of precedence as % TOPIC %.
Then why is not being resolved before ???
Is this a missing feature?
Can it be fixed?
Or is made like that in purpose?
Nested search is a solution but it is hard to maintain and not clean.
Using
FormQueryPlugin can be another solution, but still it seems much cleaner to me to have being resolved “before” the .
Thanks
--
IsmaelAntadillas - 01 Apr 2006
Never mind. As of TWiki 4.0.2 you can execute the previous statement successfully. Meaning
%FORMFIELD%
is expanded before executing the
%SEARCH%
.
This is great. I am very happy.
E.g.
%SEARCH{"ResultNo%FORMFIELD{"TestNumber"}%" scope="topic" ...other options...
You can also use it with Parameterized Includes.
E.g.
%INCLUDE{"TestResultTable" RESULTNUMBER="ResultNo%FORMFIELD{"TestNumber"}%"}%
Thanks
--
IsmaelAntadillas - 04 Apr 2006