TiddlyWiki Does not Set Field Value at The Right Time

  1. Got to http://tiddlywiki.com/
  2. Create a tiddler with below content and save
\procedure myTid()       thisTemp-Tiddler
\procedure anotherTid()  anotherTemp-Tiddler

\procedure this-actions()
<$action-listops $tiddler=<<myTid>> $field=text $subfilter="+[toggle[yes],[no]]"/>

<%if [<myTid>get[text]match[yes]] %>
		<$action-setfield $tiddler=<<anotherTid>>  $field="criteria" $value="no"/>
		<$action-setfield $tiddler=<<anotherTid>>  $index="ct" $value="yes"/>
		<$action-setfield $tiddler=<<anotherTid>>  $index="rtp" $value="yes"/>
	<%else%>
		<$action-setfield $tiddler=<<anotherTid>>  $field="criteria" $value="yes"/>
		<$action-setfield $tiddler=<<anotherTid>>  $index="ct" $value="no"/>
		<$action-setfield $tiddler=<<anotherTid>>  $index="rtp" $value="no"/>
<%endif%>
\end		


;Criteria
: thisTemp-Tiddler: Text field →   {{thisTemp-Tiddler}}

<$button actions=<<this-actions>> >
 Action
</$button>

;Results
: anotherTemp-Tiddler: Criteria field →  {{anotherTemp-Tiddler!!criteria}}
: anotherTemp-Tiddler: CT inded  → {{anotherTemp-Tiddler##ct}}
: anotherTemp-Tiddler: RTP index → {{anotherTemp-Tiddler##rtp}}

Now click the button, it seems the <%if [<myTid>get[text]match[yes]] %> always uses the value of [<myTid>get[text]] from previous step. (there is a delay, as the result of <$action-listops $tiddler=<<myTid>> $field=text $subfilter="+[toggle[yes],[no]]"/> is not used at the same run step.)

How to fix this issue?

  • This means TW does not refresh the thisTemp-Tiddler correctly and it will be updated at the end of run, so the most recent value cannot be used.
  • Partial solution, I replaced the true part with the false part in the above if-then-else, but it is confusing!

Have a look at https://tiddlywiki.com/#ActionWidget%20Execution%20Modes

1 Like

Add this line at the start of your this-actions() macro:

<$let tv-action-refresh-policy=always>

-e

1 Like

Thank you both! Works as expected now.
Much appreciated!