Question
How can I save my search results in a variable that I can use in a Select Value field of a form. The following script when executed returns a list of registered users. How can I get store this list into a variable that I can reuse in another task.
%SEARCH{"%META:FORM.*[U]serForm" web="%MAINWEB%" regex="on" casesensitive="on" nosearch="on" format="<option>$topic</option>" sort="topic" excludetopic="Test*, TWiki*"}%
I would like to store the search results in a variable like TWIKI_USERS and then when I use %TWIKI_USERS% anywhere, I should be able to see the list of TWiki users returned by the search script.
Environment
--
AlokNarula - 28 Nov 2006
Answer
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.
The short answer is that currently there is no mechanism to accomplish exactly what you describe. I know because I've been looking for this capability for some time as described in
DynamicDataSets (maybe not the greatest name). I wish there was because I can think of all kinds of extremely useful use-cases - yours being a good example.
Short of a full solution, you might take a look at
AttachContentPlugin which provides a
partial solution. You could define the search in a topic and then cache that result as an attachement and reference the attachment. The problem with this approach is that the cache only gets updated with the topic is edited. Therefore, in your case, the cached list of users may not be current.
One other comment: you do realize that you can simply include your search above directly in the select form element and it will work. And if you don't have too many users, it will work fine. The only change you'll need to your search is to add
separator=" " or else the default new-line separator will break your form definition.
--
LynnwoodBrown - 28 Nov 2006
You can use a
SpreadSheetPlugin variable to store a search result as a list. Then you can do list manipulation to do something with it.
Using your example, but limiting to topics starting with "Aa" due to the number of users on twiki.org:
1. Do a SEARCH and assign the topic list to a
topics variable: (view raw to see how)
2. The result is now in the
topics variable, value after some cleanup:
AadjanvanderHelm, AafaqueKhan, AakankshaSingh, AakashBishnoi, AakashJiyani, AamerFattah, AamirIbrahim, AamirMalik, AamirSheriff, AanRahman, AanandMurugiah, AaratiManel, AarneSaarnio, AarohiAmitSharma, AaronAbsalbekov, AaronBCaine, AaronBLingwood, AaronBarr, AaronBlack, AaronBrooks, AaronBrown, AaronBryenton, AaronBueg, AaronCalaquian, AaronCdeBruyn, AaronClaessens, AaronClark, AaronCoday, AaronColeman, AaronConner, AaronCraigie, AaronCrews, AaronCutchin, AaronDanker, AaronEvans, AaronFalk, AaronFossum, AaronFowler, AaronFuleki, AaronFulkerson, AaronGarcia, AaronGerman, AaronGibbs, AaronGibralter, AaronGrant, AaronGrill, AaronGruber, AaronGunning, AaronHairston, AaronHarding, AaronHarrison, AaronHathaway, AaronHayes, AaronHecker, AaronHockett, AaronHollenberg, AaronHooley, AaronHoover, AaronHuebner, AaronIsaac, AaronJacko, AaronJohnson, AaronKaneshiro, AaronKnecht, AaronKnister, AaronLWalker, AaronLangford, AaronLawson, AaronLemons, AaronLhiu, AaronLoessbergZahl, AaronMJohnson, AaronMacy, AaronMaynard, AaronMcKay, AaronMilbury, AaronMildenstein, AaronNauman, AaronNelson, AaronOReilly, AaronPaker, AaronPauli, AaronPhillips, AaronPott, AaronPratt, AaronRSeitz, AaronRau, AaronRichardson, AaronRoquena, AaronRossi, AaronScamehorn, AaronSeitz, AaronShaw, AaronSiegertsz, AaronSim, AaronSnape, AaronSteinmetz, AaronStollar, AaronStriegel, AaronSundstrom, AaronSwihart, AaronTye, AaronWHarvey, AaronWalker, AaronWebb, AaronWee, AaronWellls, AaronWen, AaronWhitehead, AaronWilliams, AaronWint, AaronZall, AaronZhong, AartiMohan, AasaKlevenstam, AatishShekhar
3. Now you can use a LISTMAP function to create a select with options:
--
PeterThoeny - 28 Nov 2006