How

68 views
Skip to first unread message

vpl

unread,
Nov 27, 2020, 1:06:00 PM11/27/20
to TiddlyWiki
Hi,

I want to update the field of tiddlers that have been filtered based on a compare operator ..
I have a set of tiddlers taged "test-1"
Each of them have a "date" field which stores a specific YYYYMMDD
I want to filter all of these tiddlers whose date value is greated than {!!testval}
And for each tiddler I want to set a specific field ('tempid') with a value

When I run the below code, the <<currentTiddler>> is note the title of the filtered tiddler bur the date value !!! So at the end the action-setfield is applied on new tiddler whose title is the date value and not my existing 'test-1" tiddlers.
It turns around this <<currentTiddler>> that I do not use correctly but cannot figure out how to solve it ...

Any expert who could help .. ??
Many thanks in advance
Vpl

\define my_test()
<$list filter="[tag[test-1]get[date]compare:date:gt{!!testval}]">
       <$action-setfield $tiddler=<<currentTiddler>> $field="tempid" $value="44444"/>
</$list>
\end 

Eric Shulman

unread,
Nov 27, 2020, 2:42:43 PM11/27/20
to TiddlyWiki
On Friday, November 27, 2020 at 10:06:00 AM UTC-8 vpl wrote:
When I run the below code, the <<currentTiddler>> is not the title of the filtered tiddler but the date value !!! So at the end the action-setfield is applied on new tiddler whose title is the date value and not my existing 'test-1" tiddlers.
\define my_test()
<$list filter="[tag[test-1]get[date]compare:date:gt{!!testval}]">
       <$action-setfield $tiddler=<<currentTiddler>> $field="tempid" $value="44444"/>
</$list>
\end 

Split the filter into two separate $list widgets, like this:
\define my_test()
<$vars testval={{!!testval}}>
<$list filter="[tag[test-1]]">
   <$list filter="[<currentTiddler>get[date]compare:date:gt<testval>]" variable="checkdate">
      <$action-setfield tempid="44444"/>
   </$list>
</$list>
</$vars>
\end 

Notes:
* $vars gets the testval from the tiddler in which the macro is invoked
* the first $list finds all tiddlers with the desired tag and sets currentTiddler
* the second $list compares the date of the currentTiddler to the testval
* the second $list uses the variable="..." syntax to avoid changing the value of the currentTiddler
* $action-setfield sets the tempid field value in the currentTiddler

enjoy,
-e

vpl

unread,
Nov 27, 2020, 3:24:34 PM11/27/20
to TiddlyWiki
Arghhhh how do you do that ... like a magic wand that tells you that you will not be able to redo it yourself ...

Many thanks. It works perfectly

Regards

TW Tones

unread,
Nov 27, 2020, 3:32:15 PM11/27/20
to TiddlyWiki
vpl,

You may need the temporary value stored for some reason, but sometimes it is possible to simply calculate it each time you need it. 

For others reading this thread the macros from vpl and Eric are used inside a trigger such as the button widget to get the action-setfield to work.

Tones 

Reply all
Reply to author
Forward
0 new messages