One problem here is that the code inside of the $button, including your
$action widgets, are parsed/rendered once when the Button itself is
displayed, and will not be updated as the underlying Wiki tiddlers change
(for example, once that Button is onscreen, changes to the list of Tagged
tiddlers will not be picked up).
In order to work around this, it is recommended that you pass all actions
that need complex wikitext to a button as-a-macro-parameter to the
"actions" parameter. This causes the wikitext in the actions block to be
parsed and "rendered" at the time the button is clicked. Like so:
\define buttonActions()
<$list filter="[tag[Mark]]">
<!--add global exhibition_id to the exhibition_id list-field of each
marked artwork tiddler-->
<!--$listops $subfilter will append any new filter run to the existing
list-field-->
<$action-listops
$field="exhibition_id"
$subfilter="[{$:/TLS/exhibition_id}]"
/>
<!--append each artwork_id to artwork_id list-field of the exhibition
tiddler-->
<$action-listops
$tiddler= {{{ [{$:/TLS/exhibition_id}] }}}
$field="artwork_id"
$subfilter="[{$:/TLS/artwork_id}]"
/>
</$list>
\end
<$button actions=<<buttonActions>> >
Link Artworks to Exhibition
</$button>
Best,
Joshua Fontany
On Monday, October 5, 2020 at 12:10:48 AM UTC-7 TW Tones wrote:
> Bob,
>
> I have not seen a fault yet, I will keep looking, however when adding
> items to a list consider using the ActionListops widget
> <https://tiddlywiki.com/#ActionListopsWidget>rather than adding suffixes.
> It has the advantage of not setting it twice etc...
>
> Your second attempt at the first action set field will store each tiddler
> tagged Mark in _null thus current tiddler will be the currentTiddler
> running when you click the button.
>
> When debugging buttons
>
> - you can make large buttons by displaying an intermediate result as
> the button title to see the output.
> - Your can also make the same loop as just a list, and text what your
> logic generated before you hide it with actions tiddlers when don't
> themselves present output, just actions.
>
> <$list filter="[tag[Mark]]">
> <!--append exhibition_id to exhibition_id of each marked artwork
> tiddler-->
>
>
> action-setfield
> $field="exhibition_id"
> $value={{{ [{!!exhibition_id}addsuffix[
> ]addsuffix{$:/TLS/exhibition_id}] }}}
> `{{{ [{!!exhibition_id}addsuffix[
> ]addsuffix{$:/TLS/exhibition_id}] }}}`
>
>
> <!--append each artwork_id to artwork_id of the exhibition tiddler-->
>
> action-setfield
> $tiddler= {{{ [{$:/TLS/exhibition_id}] }}}
> $field="artwork_id"
> $value={{{ [{$:/TLS/exhibition_id!!artwork_id}addsuffix[
> ]addsuffix{$:/TLS/artwork_id}] }}}
> `{{{ [{$:/TLS/exhibition_id!!artwork_id}addsuffix[
> ]addsuffix{$:/TLS/artwork_id}] }}}`
>
>
> </$list>
>
> See how I replicated the tripl braces, keep both upto date as you test you
> outcomes
>
> - I basically converted the otherwise actions into text and took it
> outside of the button.
>
> Regards
> Tony
>
> On Monday, 5 October 2020 17:05:50 UTC+11, Bob Jansen wrote:
>>
>> I am trying to implement a simple function in my TW.
>>
>> <code>
>> <$button>
>> <$list filter="[tag[Mark]]">
>> <!--append exhibition_id to exhibition_id of each marked artwork
>> tiddler-->
>>
>> <$action-setfield
>> $field="exhibition_id"
>> $value={{{ [{!!exhibition_id}addsuffix[
>> ]addsuffix{$:/TLS/exhibition_id}] }}}
>> />
>>
>> <!--append each artwork_id to artwork_id of the exhibition tiddler-->
>>
>> <$action-setfield
>> $tiddler= {{{ [{$:/TLS/exhibition_id}] }}}
>> $field="artwork_id"
>> $value={{{ [{$:/TLS/exhibition_id!!artwork_id}addsuffix[
>> ]addsuffix{$:/TLS/artwork_id}] }}}
>> />
>>
>> </$list>
>>
>> Link Artworks to Exhibition
>> </$button>
>> </code>
>>
>> The first action-setfield works. The second one doesn't but I can not
>> determine why. It differs from the first in that the first is editing a
>> field of the <currentTiddler> from a $list widget whilst the second is
>> editing a field of a tiddler whose title is stored in the tiddler
>> $:/TLS/exhibition_id.
>>
>> Is it possible to edit a tiddler not part of the $list widget set?
>>
>> To my understanding, there are essentially two transclusions involved,
>> first to get to the tiddler whose title is in $:/TLS/exhibition_id and the
>> second to the field artwork_id stored in this tiddler.
>>
>> From Tones' excellent cheat sheet, I thought I has it right but obviously
>> not.
>>
>> There is obviously an error in my wikitext. But what??
>>
>> Secondly, an earlier query regarding conditional operators with some
>> advice from Saq Imtiaz.
>>
>> I want to only perform the action-setfield if the value to be inserted is
>> not already in the field.
>>
>> I thought this would work (replacement for the first action-setfield
>> statement from above).
>> <code>
>> <$list [{!!exhibition_id}!contains{$:/TLS/exhibition_id}]
>> variable="_null" >
>> <$action-setfield
>> $field="exhibition_id"
>> $value={{{ [{!!exhibition_id}addsuffix[
>> ]addsuffix{$:/TLS/exhibition_id}] }}}
>> />
>> </$list>
>> </code>
>> but it doesn't.
>>
>> What an I doing wrong here?
>>
>> bobj
>>
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/9bf12d31-1e8d-494f-96cd-ce937d9ef9a0n%40googlegroups.com.