Set field to multiple tiddlers

Hi,

can i use set action field against multiple tiddlers
also can i have a these actions based off multiple tags

for example if i have tiddler A tagged with B and C , how can i set a button to in tiddler A , to do actions in tiddlers that A is tagged with , B and C

so suppose i want to set a field called my field to the value “done” in all tiddlers matching the tags A has ? so set the myfiled value in tiddler B and Tiddler C to “done”

i can easily do this button for a single tiddler ,but looking off only one value as criteria from a user defined field , not 2 values in the tag field

so i can do this

<$button>set to done
<$set name="tiddlertobetagged" value={{{[{!!tiddlertobetagged}]}}}>
<$action-setfield $tiddler= <<tiddlertobetagged>>  myfield= "done"/>
</$set>
</$button>

how can i change the above code to affect multiple tiddlers using the tag field

thanks

You can wrap the action widget inside a list, that effectively generates multiple actions widgets. The whole thing is inside the button which is the trigger, or use the actions parameter

\define my-actions()
<$list filter="A B C">
   <$action-setfield $tiddler= <<currentTiddler>>  myfield= "done"/>
</$list>
\end

<$button actions=<<my-actions>> >
Go
</$button>
  • In this example clicking the Go button triggers the my-actions which sets myfield to done on the tiddler A B and C.

This example is not exactly what you asked for, but an example which you can adapt.

1 Like

Thanks tones,

well i have done this , figured kin would be fastest to get the tags , didnt work what am idoing wrong

\define my-actions()
<$list filter="[kin::from:1:<currentTiddler>]">
   <$action-setfield $tiddler= <<currentTiddler>>  myfield= "done"/>
</$list>
\end

<$button actions=<<my-actions>> >
Go
</$button

or how do i list the tags in my current tiddler ?then use these values as tiddler titles to do an action against

<$list filter="[all[current]tags[]]">...

The easy ways to test is {{{ [all[current]tags[]] }}}

However you use the kin to also get the tags of tags etc…

The kin operator is harder to use until you learn its format.

got it! , thanks tones

Sorry for comming back again

but i tried to use it with a different action ,my ultimate goal was to have a button to decrement values in tagged tiddlers , the action only happens on one tiddler and not both ,it also seems to be random , ithink it goes for whichever tag was applied first to the tiddler , i dont know . the decrement action works on single tiddlers fine if i use single values in a user defined field .

i think its unable to process multiple values , am icorrect ?

\define decrementtest(field:counter)

<$set name="myfieldvalue" value={{{[all[current]tags[]]}}}>

<$tiddler tiddler=<<myfieldvalue>>>
<$action-setfield  $tiddler =<<myfieldvalue>>$field=$field$ $value={{{[all[current]get[$field$]!is[blank]else[0]subtract[1]]}}}/>

\end

<$button actions=<<decrementtest increment>> >
Go
</$button>

Hey,

First check this thread out. How to use buttons to add and subtract numerical value to fields by 1

Then stop and think if you want a button that changes multiple tiddlers, do you want a button for each tiddler?

1 Like

thank you checking out

one button , multiple tiddlers, i think what i am missing is how to get the action happen on all listed values , it seems to be only picking up on the first one value and not the rest.
its that part

{{{[all[current]get[$field$]!is[blank]else[0]subtract[1]]}}}

my problem is that part seems to run only on the first value it finds then stops , thus taking the action only on one tiddler

the thread is great , but it deals with the use case of one tiddler ,and not multiple tiddlers

i am still stuck any ideas

Try this:

\define decrementtest(field:counter)
<$list filter="[<currentTiddler>tags[]]" variable="thisTag">
<$action-setfield $tiddler=<<thisTag>> $field=$field$ $value={{{ [<thisTag>get[$field$]subtract[1]else[0]] }}}/>
</$list>
\end
<$button actions=<<decrementtest increment>>>Go</$button>

Thank you Eric,

So does this mean that setname does not work for multiple values, and instead i should use a list filter with a variable?

also is there documentation on how to use a variable with filters like you did

thanks again

If you omit the variable="thisTag" syntax, the $list widget defaults to using currentTiddler as the variable. Thus, you could write:

\define decrementtest(field:counter)
<$list filter="[<currentTiddler>tags[]]">
<$action-setfield $field=$field$ $value={{{ [<currentTiddler>get[$field$]subtract[1]else[0]] }}}/>
</$list>
\end
<$button actions=<<decrementtest increment>>>Go</$button>

Note that the <currentTiddler> in the $list widget’s filter parameter refers to the tiddler that contains the above code, while the <currentTiddler> that is in the $action-setfield widget’s $value parameter refers to each tag value that is the result of the $list widget’s processing of the “[<currentTiddler>tags[]]” filter.

Also note that the $action-setfield's $tiddler parameter defaults to using the <currentTiddler> value (i.e., the tag value), so that parameter can also be omitted to simplify the code.

HOWEVER, for readability and clarity, it is often helpful to specify a variable name (i.e., variable="thisTag") so that there is less chance of confusing what each instance of currentTiddler is referring to.

1 Like