Tags:
create new tag
view all tags

SID-00801: PerformSearchBasedOnListSearchResult

Status: Answered Answered TWiki version: 4.3.1 Perl version: 5.8.2
Category: CategorySearch Server OS: AIX 5.3 Last update: 15 years ago

Hello, I apologize if this has been asked elsewhere.

I have a series of topics with formfields "ServerName" (single value) and "PrereqServers" (possibly empty list of servernames). I would like to be able to walk through the "PrereqServers" values, searching to find the values in the "ServerName" field of other topics. I haven't been able to get anything to work right yet.

Not sure of the best way to walk through the "prerequisites" list - I've tried with FORMATLIST and SEARCH, but have not had luck (I would love to format the list as item1|item2|etc., and include that in the SEARCH text, but it doesn't like it)

So, I know several ways to create a pipe-separated list, but I have not been successful in injecting that in the search argument. And, alternatively, I'm not sure how to use a conditional CALC in the format field to look for a match (FIND seems ok, but I guess, since this is originally a comma-separated list, I would need to TRANSLATE or otherwise to get rid of the commas).

Any recommendations?

Some searches so far:

  • This brings back the pipe-separated list of prereq servers:
    %SEARCH{ "[P]rereq[S]ervers.*value\=.*[A-Za-z]+" topic="%INCLUDINGTOPIC%" type="regex" casesensitive="off" nosearch="on" nototal="on" format="$percntCALC{$LISTJOIN(|,$formfield(PrereqServers))}$percnt" }%

    As does this:
    %FORMATLIST{"$percntFORMFIELD{\"PrereqServers\" topic=\"%INCLUDINGTOPIC%\"}$percnt" header=" " footer=" " sort="on" separator="|" format="$1"}%
  • But I can't get them properly injected into this search:
    %SEARCH{ "[S]erver[N]ame.*value\=.*(<POSSIBLY_NEST_SEARCH_HERE>)" topic="DRServerSheetEventID*" type="regex" casesensitive="off" nosearch="on" nototal="on" format="| $formfield(ServerName) [[$web.$topic]] | $percntCALC{\"$FORMATTIME($TIMEADD($TIME(%DRSTARTDATE%), $formfield(TargetTime), hour), $year-$month-$day - $hour:$minute)\"}$percnt | $formfield(CurrentState) | $formfield(CurrentOwner) | $formfield(Description) |" }%

-- AaronLWalker - 2010-03-29

Discussion and Answer

Long story short, in a topic have formfield X, with value = a,b,c and I want to add a search in that topic for other topics where formfield Y has value a, or b, or c.

I've just been unsuccessful in the nesting of the searches. Thanks.

-- AaronLWalker - 2010-03-30

The FOREACH plugin does most of the work for me, but I still haven't figured out how to use this within a SEARCH.

What I want to do:

To ease maintenance, I want to set a variable as a list.

  • #Set SOMELIST = item01, item02, item03, item04

Then, I use this list to:

  1. populate drop-down boxes (easy):
    %FOREACH{"trip" in="%SOMELIST%"}% <option>$trip</option> %NEXT{"trip"}%
  2. populate column headers in a table (easy):
    (same idea)
  3. and formfield indexes (ouch) - i.e. within a search I want to be able to have $formfield(item01), $formfield(item02), etc.

This last one is not working out yet. (my SEARCH output is a table)

 $percntFOREACH{"trip" in="%SOMELIST%"}$percnt $formfield($trip) | $percntNEXT{"trip"}$percnt 

NOR

 $percntCALC{$TRANSLATE($LISTMAP( $formfield($item) , %SOMELIST%), $comma, $CHAR(124) )}$percnt 

Nothing is working right yet, trying every possible substitution I could think of for dollar signs, percent, etc.

Any ideas? It will be tougher to sell this to my users if they have to change things in multiple places if they want to add or change an item in SOMELIST.

-- AaronLWalker - 2010-04-29

Got it to work.

   * Set TRIPLIST = %FORMATLIST{"%%URLPARAM{"alLoc" default="EMPTY"}%TRIPS%" header=" " footer=" " sort="off" separator=" | " format=" $formfield($1) "}%
   * Set TRIPHEAD = %FOREACH{"triphead" in="%%URLPARAM{"alLoc" default="EMPTY"}%TRIPS%"}% *$triphead* | %NEXT{"triphead"}%
   * Set STARTINGCOL = 10
   * Set LOCS = Site01, Site02, Site03, Site04, Site05
   * Set Site01TRIPS = Trip01, Trip02, Trip03, Trip04
   * Set Site01YARD = $SUM(R$ROW():C$EVAL(%STARTINGCOL% + 8)..R$ROW():C$EVAL(%STARTINGCOL% + 15))
   * Set Site01ROAD = $SUM(R$ROW():C%STARTINGCOL%..R$ROW():C$EVAL(%STARTINGCOL% + 7))
   * Set Site01TOTAL = $SUM(R$ROW():C%STARTINGCOL%..R$ROW():C$EVAL(%STARTINGCOL% + 15))
...etc.

%TABLE{ sort="on" headerrows="1" tablewidth="100%" columnwidths="5%,*" tablerules="all"}% 
| *PIN* | *Last* | *First* | *Class* | *Location* | *Total* | *Road* | *Yard* | %TRIPHEAD%
%SEARCH{ "[L]ocation.*value\=.*%URLPARAM{"alLoc" default="EMPTY"}%" topic="NewEmpID*"  type="regex" nosearch="on" nototal="on" format="| [[$topic][$formfield(PIN)]] | $formfield(LastName) | $formfield(FirstName) | $formfield(Class) | $formfield(Location) | $percntCALC{%$formfield(Location)TOTAL%}$percnt | $percntCALC{%$formfield(Location)ROAD%}$percnt | $percntCALC{%$formfield(Location)YARD%}$percnt | %TRIPLIST% |" }%

-- AaronLWalker - 2010-05-05

      Change status to:
ALERT! 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.
SupportForm
Status Answered
Title PerformSearchBasedOnListSearchResult
SupportCategory CategorySearch
TWiki version 4.3.1
Server OS AIX 5.3
Web server IBM HTTP 7
Perl version 5.8.2
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2010-05-05 - AaronLWalker
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.