Update fields on multiple tiddlers

63 views
Skip to first unread message

Scott Kingery

unread,
Dec 31, 2019, 2:34:51 PM12/31/19
to TiddlyWiki
In a current project, I have tiddlers that use a couple of fields that keep running totals. We'll call them time_total and grand_total. I'd like to create a button that sets the value to 0 in all tiddlers containing those fields. Basically, a reset button. Has anyone crafted such a thing? I know there are tools like Mohammad's Commander Plugin and that might be the safer route but I thought I'd ask.

Scott

Eric Shulman

unread,
Dec 31, 2019, 3:11:30 PM12/31/19
to TiddlyWiki
On Tuesday, December 31, 2019 at 11:34:51 AM UTC-8, Scott Kingery wrote:
In a current project, I have tiddlers that use a couple of fields that keep running totals. We'll call them time_total and grand_total. I'd like to create a button that sets the value to 0 in all tiddlers containing those fields. Basically, a reset button. Has anyone crafted such a thing? I know there are tools like Mohammad's Commander Plugin and that might be the safer route but I thought I'd ask.

There are filters for finding tiddlers with specific fields.  Thus:

<!-- show tiddlers and values (just so we know it works) -->
<$list filter="[has[time_total]] [has[grand_total]]">
   <
<currentTiddler>> time_total={{!!time_total}} grand_total={{!!grand_total}}<br>
</$list>

<!-- HERE'S THE BUTTON -->
<$button> reset totals
   <$list filter="[has[time_total]] [has[grand_total]]">
      <$action-setfield time_total="0" grand_total="0" />
   </$list>
</$button>

note: the filter tests for any tiddler that has *non-blank* values for time_total OR grand_total.  If you want to test for tiddlers that have either of those fields, even if blank, use:
<$list filter="[has:field[time_total]] [has:field[grand_total]]">

enjoy,
-e



Scott Kingery

unread,
Jan 1, 2020, 11:33:49 PM1/1/20
to TiddlyWiki
Thanks, Eric. Worked as advertised and gave me some examples for the future.
Reply all
Reply to author
Forward
0 new messages