On Friday, July 31, 2020 at 12:41:19 PM UTC-7, Mark Hylton wrote:
>
> How do I programmatically build a string to be used as the title for a new 
> tiddler (<$button> ... $message="tm-new-tiddler" ... title=???)?
> I'm trying to use <$button> to start a new tiddler, but I can't get the 
> title set the way I wish. What I want the new tiddler title to be (for 
> instance) is "*A1234,Risk (2020-07-27 15:00:00): *", where:
>

Here's my solution:
\define newRisk_button() <$button actions=<<newRisk_actions>>> New project 
risk entry </$button>

\define newRisk_actions()
<$vars
   projnum={{{ [<storyTiddler>get[projectnumber]] }}}
   time=<<now "YYYY-0MM-0DD 0hh:0mm:0ss">>
>
<$action-sendmessage $message="tm-new-tiddler"
   title={{{ [<projnum>addsuffix[,Risk (]addsuffix<time>addsuffix[)]] }}}
   tags={{{ [<projnum>addsuffix[ risk]] }}}
   text={{creationtemplateRisk}}
   projectnumber=<<projnum>>
/>
</$vars>
\end

Need to document a new project risk?
Click this button: <<newRisk_button>> to create a new risk tiddler with 
this [[template|creationtemplateRisk]]
and tagged with <$macrocall $name="tag" tag={{{ 
[<storyTiddler>get[projectnumber]] }}} /> and <<tag risk>>

Notes:
* newRisk_button() macro outputs a $button widget (note the *single-line* 
macro definition omits the \end)
* $button uses the actions="..." parameter to defer all button processing 
until the button is pressed

* newRisk_actions() macro is invoked when the $button is pressed
* $vars uses an inline filter to get the projnum value from the current 
storyTiddler's "projectnumber" field
* It also get the time value using the <<now>> macro
* $action-sendmessage triggers tm-new-tiddler to create a new tiddler
* the title param uses an inline filter to construct the new title from the 
projnum and time
* the tags param uses an inline filter to construct the new tags from the 
projnum and "risk"
* the text param fetches the template contents
* the projectnumber param adds a field with the value of the projnum

Then:
the text of the tiddler shows the newRisk_button and a link to the template
along with "tag pills" for the current storyTiddler's project number and 
the "risk" tag.

enjoy,
-e

-- 
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/2fd609c3-7f37-47fe-8341-899b2c959d20o%40googlegroups.com.

Reply via email to