This question about Documentation: Answered

Search for other topics that contain a given value in a given DataForm field

I want to create a search (for use in a macro) along these lines: show me a list of pages in which the field Extension contains the same value as the current topic's field Extension.

This question is very similar to Question575, with one important difference:
  • Question575 = how to find topics that have the same value in a form field -- i.e. an exact match.
  • This question = how to find topics that contain a value in a form field -- i.e. a match with wildcards, because the field can have multiple selections and I want to match all occurrences.

MartinKaufmann gave this solution, but I need to modify it and lack the regex skills:
%SEARCH{type="query" "QuestionForm[name='Extension'].value='%FORMFIELD{Extension}%'"}%

I have tried adding the regex wildcard .* so the search would be
"QuestionForm[name='Extension'].value='.*% FORMFIELD{Extension}%.*'"
but the result is empty (I deliberately added the space in this example; it's not in the actual search of course).

Here is an example using Attachment instead of %FORMFIELD {Extension}% that should show topics whose Extension contain "Attachment":
%SEARCH{type="query" limit="3" "QuestionForm[name='Extension'].value='.*Attachment.*'"}%
And in use:
Searched: QuestionForm[name='Extension'].value='.*Attachment.*'
Number of topics: 0

How can I properly add wildcards to the search?

Answer

You can try FormFieldListPlugin.

-- ArthurClemens - 05 Aug 2010

I think you need to change the operator from = to ~ as it says in the QuerySearch. Should not need extra plugins for this.

%SEARCH{type="query" limit="3" "QuestionForm[name='Extension'].value ~ '.*Attachment.*'"}%

-- LarsEik - 05 Aug 2010

A-HA! Thank you LarsEik for the link to QuerySearch. I tried your exact suggestion but that didn't work. Then I read http://foswiki.org/System/QuerySearch#Operators and found that the wildcard operator is not regex but simply *. So this works:
%SEARCH{type="query" limit="3" "QuestionForm[name='Extension'].value~'*Attachment*'"}%
gives:
Searched: QuestionForm[name='Extension'].value~'*Attachment*'

Results from Support web retrieved at 18:56 (GMT)

Question1041
Hi there, The task I have is: on a wiki page there is an attached file, a certain logbook, which is synchronized, i.e. downloaded to ../pub/ from another machine ...
Question1124
* I installed MsOfficeAttachmentsAsHTMLPlugin, Version: 3575 (2009 04 20) * I tried to attach a .doc file * I get this error During save of Sandbox.BagelTwo...
Question1238
Hi I have a Dataform that contain Topic Relevant Checkbox 7 Project Framework Execution, Generic Processes, Product System, Software, Hardware, Mechan...
Number of topics: 3

-- TorbenGB - 06 Aug 2010

QuestionForm edit

Subject Documentation
Extension
Version Foswiki 1.0.9
Status Answered
Topic revision: r4 - 06 Aug 2010, TorbenGB
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy