$:/tags/StartupAction not executed

Hello,
I have a tiddler named “Heures lever/coucher soleil get” which gives me a button to manually launch a procedure that retrieves a JSON and puts it in the tiddler “Heures lever/coucher soleil données”.

Heures lever/coucher soleil get

\whitespace trim

\procedure store-fetched-output()
<$action-setfield $tiddler="Heures lever/coucher soleil données" text=<<data>>/>
\end

\procedure http-get()
	<$action-sendmessage $message="tm-http-request"
	url="https://api.sunrisesunset.io/json?lat=LATITUDE&lng=-LONGITUDE&timezone=UTC&time_format=24"
	method="GET"
	oncompletion=<<store-fetched-output>>
	/>
\end

<$button class="tc-btn-invisible" actions=<<http-get>>>{{$:/core/images/refresh-button}}</$button>

Example : Heures lever/coucher soleil données

{"results":{"date":"2025-03-10","sunrise":"06:27:02","sunset":"17:59:32","first_light":"04:41:00","last_light":"19:45:34","dawn":"05:55:22","dusk":"18:31:12","solar_noon":"12:13:17","golden_hour":"17:17:06","day_length":"11:32:29","timezone":"UTC","utc_offset":0},"status":"OK"}

I’ve added this tag “$:/tags/StartupAction” to the file “Heures lever/coucher soleil get” so that the ActionWidget is executed on startup, but nothing happens.

Any ideas?

The “Heures lever/coucher soleil get” tiddler just renders a $button widget, so the <<http-get>> action is only performed when the button is pressed. To also execute this action on startup, you would need to invoke <<http-get>> independent of the $button widget.

Thus, you can write the following:

<$button class="tc-btn-invisible" actions=<<http-get>>>{{$:/core/images/refresh-button}}</$button>
<<http-get>>

When this tiddler is displayed in the StoryRiver, the $button widget is rendered as usual, but the separate <<http-get>> will do nothing, since the $action-sendmessage is not triggered by rendering the tiddler content.

Conversely, when this tiddler is invoked as a StartupAction, the $button widget does nothing, since rendered output is not generated at that time, but the separate <<http-get>> IS performed, so the $action-sendmessage is triggered to fetch the desired JSON data.

Note that if your intent is to ONLY perform the action at startup, you can completely omit the $button widget.

enjoy,
-e

1 Like

Hi EricShulman,
Thanks for your reply, it’s very clear and it works!
Thanks again!