Storing field value in variable

Hi

I am trying to store a field value in a variable using the below code , myvariable gets some tiddlers maching the filter, then myvariable2 captures their “myfield” field value , but i must be doing something wrong because mybariable2 doesnt seem to show any results

<$set name=myvariable filter="[tag[done]]">

<$set name="myvariable2"  tiddler= <<myvariable>> field="myfield">
<$text text=<<myvariable2>>/>

If you want to write to a tiddler field, you need to use the action-setfield widget

But … actions widgets need user interaction to be activated. So there will need to be a button widget somewhere

Thanks,

but i am not trying to write , i just want to fetch the existing value , store it in a variable so that i can pass it in another macro

Have a closer look at the set-widget documentation. Especially the tiddler parameter is a “read” parameter. … It’s not the way how it works. You’ll need to define the “value” param.

https://tiddlywiki.com/#SetWidget

The first $set widget sets myvariable to a LIST of tiddler titles that match the [tag[done] filter. Then, in the second $set widget, you use <<myvariable>> as the value for the tiddler param, but that param expects a SINGLE tiddler title.

If you want to display the myfield value for each title, you could do something like this:

<$list filter="[tag[done]]">
   <$text text={{{ [<currentTiddler>get[myfield]] }}}/>
</$list>

and, to pass each myfield value to another macro:

<$list filter="[tag[done]]">
   <$macrocall $name="mymacro" someparam={{{ [<currentTiddler>get[myfield]] }}} />
</$list>
2 Likes

got it sorted , thanks for your help as always