How to set multiple tags with a $action-setfield if one of those tags is defined in a macro

I can set a tag, but I can’t set more than one if a macro is involved
If I have:

<$set name=ExampleTag value="$:/tag1">
...
<$action-setfield $tiddler=XXX list=XXX tags=<<ExampleTag>>/>
...
</$set>

And at the same time I would like to set a second tag $:/tag2.

  • How can I do it?

Have a closer look at the actions-listops widget … See the 3rd example

https://tiddlywiki.com/#ActionListopsWidget:ActionListopsWidget%20[[ActionListopsWidget%20(Examples)]]

I’m sorry, I’ve tried almost all of them, but unfortunately I didn’t understand how to do it

The first button of the 3rd example looks similar to the following code. I moved the action-widget into an action-macro because of best practice.

\define setTags() 
<$action-listops $tiddler=test $tags="a b c"/>
\end
<$button actions=<<setTags>> >
Populate 'tags'
</$button>

First of all, I thank you for your patience, and apologies for my stubbornness

Can this be done within the $action-setfield itself, without using listops?
-Maybe I’m very incompetent or maybe I explained myself badly. In case I explained myself badly, I’ll give more context (which perhaps was necessary, but I didn’t want to put it at first so as not make people read too much unnecessary text)
I tried to insert, or modify already existing parts to implement the proposed solution, but with little luck

Basically I’m trying to modify the code shared by Eric Shulman in a past google group conversation, specifically the edited version by Soren Bjornstad

What I wanted to do, was to add a second tag (along with $:/sib/StorySaver/SavedStory) to the tiddlers that are created which I usually use for all the “service” tiddlers so that I can manage them together with other settings

Full code: (Interested parties are marked with “HERE”)

<!-- Eric Shulman, https://groups.google.com/g/tiddlywiki/c/2WWN0Lf0G-E, alt. -->

<!-- HERE (1) --> <$set name=savedStoryTag value="$:/sib/StorySaver/SavedStory">
<$set name=savedStoryPrefix value="$:/sib/StorySaver/saved/">
<$button popup="$:/state/popup/savestory"> {{$:/core/images/save-button}} save story </$button>
<$reveal type="popup" state="$:/state/popup/savestory" class="tc-drop-down tc-popup-keep" style="min-width:auto;padding:0.5em;">
   Enter a new story name:<br>
   <$edit-text tiddler="$:/state/popup/savestory" field="storyname" /><br>
   <$list filter="[tag<savedStoryTag>limit[1]]">
      or, select an existing story:<br>
      <style> .savedStoryList { width:100%; } </style>
      <$select tiddler="$:/state/popup/savestory" field="storyname" size="5" class="savedStoryList">
      <$list filter="[tag<savedStoryTag>removeprefix<savedStoryPrefix>]"><option><<currentTiddler>></option></$list>
      </$select>
   </$list>
   <$button style="text-align:center;"> save
<!-- HERE (2) -->     <$action-setfield $tiddler={{{ [{$:/state/popup/savestory!!storyname}addprefix<savedStoryPrefix>] }}} list={{$:/StoryList!!list}} tags=<<savedStoryTag>> />
      <$action-deletetiddler $tiddler="$:/state/popup/savestory" />
   </$button>
</$reveal>
<$button popup="$:/state/popup/loadstory"> {{$:/core/images/storyview-classic}} load story </$button>
<$reveal type="popup" state="$:/state/popup/loadstory" class="tc-drop-down tc-popup-keep" style="min-width:auto;padding:0.5em;">
   <$list filter="[tag<savedStoryTag>limit[1]]" emptyMessage="no saved stories">
      select an existing story:<br>
      <style> .savedStoryList { width:100%; } </style>
      <$select tiddler="$:/state/popup/loadstory" field="storyname" size="5" class="savedStoryList">
      <$list filter="[tag<savedStoryTag>removeprefix<savedStoryPrefix>]"><option><<currentTiddler>></option></$list>
      </$select>
   </$list>
   <$button style="text-align:center;"> load
      <$action-setfield $tiddler="$:/StoryList" list={{{ [{$:/state/popup/loadstory!!storyname}addprefix<savedStoryPrefix>get[list]] }}} />
      <$action-deletetiddler $tiddler="$:/state/popup/loadstory" />
   </$button>
</$reveal>

<$button popup="$:/state/popup/exportstory"> {{$:/core/images/export-button}} export story </$button>
<$reveal type="popup" state="$:/state/popup/exportstory" class="tc-drop-down tc-popup-keep" style="min-width:auto;padding:0.5em;">
   <$list filter="[tag<savedStoryTag>limit[1]]" emptyMessage="no saved stories">
      select an existing story:<br>
      <style> .savedStoryList { width:100%; } </style>
      <$select tiddler="$:/state/popup/exportstory" field="storyname" size="5" class="savedStoryList">
      <$list filter="[tag<savedStoryTag>removeprefix<savedStoryPrefix>]"><option><<currentTiddler>></option></$list>
      </$select>
   </$list>
	<$macrocall $name="exportButton" exportFilter={{{ [{$:/state/popup/exportstory!!storyname}addprefix<savedStoryPrefix>get[list]] }}} lingoBase="$:/language/Buttons/ExportTiddlers/"/>
</$reveal>
</$set>
</$set>

Action set field is designed to set a fieldname to a value, and in fact allows multiples with filename=values.

  • Action listops is designed to manipulate “list fields” lists of titles as the value in a field.
  • The tags field is a list field but has a range of tools to assist from operators to messages like tm-add-tag and tm-delete tag

Not withstanding the above you could set a list field to itself plus a difference

<$action-setfield $field="tags" $value={{{ [enlist{!!tags}] [[new tag]]"/>

I’m afraid I don’t understand

In this case you can use code like this, if your tag is a fixed string.

<$set name=savedStoryTag value="$:/sib/StorySaver/SavedStory ABCDE">

If you need a variable value instead of hardcoded ABCDE … it will need to be done differently.
Basically, as soon as your usecase is different … it won’t work that way.

-m

1 Like

Man, now that I see it, it looks easy. I should have thought about it sooner.
But I didn’t, so, really, thank you for your help!