Problems getting $action-createtiddler to populate variable via SaveTitle

50 views
Skip to first unread message

MagoArcade

unread,
Jul 21, 2019, 11:00:25 AM7/21/19
to TiddlyWiki
Hi all - I can't figure out how to save the final name used by $action-createtiddler into a variable in the originating tiddler. Basically, I want to enter all of the data used in a template tiddler's field and then click a button and a new tiddler is created with the relevant fields populated with the text boxes for the originating tiddler. 

The code below:

!Add Task
--------------
Task Name: <$edit-text tiddler="NewTask" tag="input" default="New Task" class='tc-edit-texteditor' placeholder='New Task'/>


Brief Description: <$edit-text tiddler="BriefDesc" tag="input" default="no-one" class='tc-edit-texteditor' placeholder=''/>


Asigned to: <$edit-text tiddler="AssignedTo" tag="input" default="no-one" class='tc-edit-texteditor' placeholder='no-one'/>


<$button>New Task


<$action-createtiddler $basetitle='{{NewTask}}' $savetitle=tasksavetitle/>


<$action-navigate $to={{!!tasksavetitle}}/>


<$action-setfield $tiddler='_templateTask' $field='title' $value={{NewTask}}/>


<$action-setfield $tiddler='_templateTask' $field='caption' $value={{BriefDesc}}/>


<$action-setfield $tiddler='_templateTask' $field='tmap.id' $value={{{ [[]make[%uuid%]] }}} />


<$action-setfield $tiddler='_templateTask' $field='assignedto' $value={{AssignedTo}} />


<$action-deletefield $tiddler=NewTask text/>
<$action-deletefield $tiddler=AssignedTo text/>
<$action-deletefield $tiddler=BriefDesc text/>
</$button>
<br>

The problem bit is this:

<$action-createtiddler $basetitle='{{NewTask}}' $savetitle=tasksavetitle/>


<$action-navigate $to={{!!tasksavetitle}}/>


The official info here suggests the final title used can be saved into a field or an index. So I created a field in my originating tiddler (i.e. the one this code is in) called "tasksavetitle". However, it doesn't appear to be populating. 

I basically just need a variable to pass to $action-navigate. As ever the tw wiki is a bit ambiguous/short on details.

Can anyone help?

Watt

unread,
Jul 21, 2019, 12:28:44 PM7/21/19
to TiddlyWiki
Hi MagoArcade

Here's one attempt. It looks like there's a bit of duplication but maybe that's how you need it. Other forum users will almost certainly have better solutions but this might work for you.

!Add Task
--------------
Task Name: <$edit-text tiddler="NewTask" field=NewTask tag="input" default="New Task" class='tc-edit-texteditor' placeholder='New Task'/>


Brief Description: <$edit-text tiddler="NewTask" field="BriefDesc" tag="input" default="no-one" class='tc-edit-texteditor' placeholder=''/>


Asigned to: <$edit-text tiddler="NewTask" field="AssignedTo" tag="input" default="no-one" class='tc-edit-texteditor' placeholder='no-one'/>


<$button>New Task


<$action-setfield $tiddler='_templateTask' $field='NewTask' $value={{NewTask!!NewTask}}/>

<$action-setfield $tiddler='_templateTask' $field='caption' $value={{NewTask!!NewTask}}/>


<$action-setfield $tiddler='_templateTask' $field='BriefDesc' $value={{NewTask!!BriefDesc}}/>

<$action-setfield $tiddler='_templateTask' $field='tmap.id' $value={{{ [[]make[%uuid%]] }}} />

<$action-setfield $tiddler='_templateTask' $field='AssignedTo' $value={{NewTask!!AssignedTo}} />

<$action-createtiddler $basetitle={{_templateTask!!NewTask}} $savetitle=tasksavetitle BriefDesc={{_templateTask!!BriefDesc}} AssignedTo={{_templateTask!!AssignedTo}} caption={{_templateTask!!caption}} tmap.id={{_templateTask!!tmap.id}} />

<$action-setfield $tiddler=NewTask NewTask=''/>
<$action-setfield $tiddler=NewTask caption=''/>
<$action-setfield $tiddler=NewTask AssignedTo=''/>
<$action-setfield $tiddler=NewTask BriefDesc=''/>
<$action-setfield $tiddler=_templateTask NewTask=''/>
<$action-setfield $tiddler=_templateTask AssignedTo=''/>
<$action-setfield $tiddler=_templateTask BriefDesc=''/>
<$action-setfield $tiddler=_templateTask caption=''/>
<$action-setfield $tiddler=_templateTask tmap.id=''/>

<$action-navigate $to={{tasksavetitle}}/>
</$button>
<br>

MagoArcade

unread,
Jul 21, 2019, 2:26:43 PM7/21/19
to tiddl...@googlegroups.com
Thanks Watt. In the end I went for another approach, leveraging a single, temporary tiddler; populating all fields from action-createtiddler (avoiding all that clumsy action-navigate stuff) and seems to work OK:

!Add Task
--------------
Task Name: <$edit-text tiddler="$:/_opTaskStore" field="taskname" tag="input" default="" class='tc-edit-texteditor' placeholder='Type a new task name here'/>

Brief Description: <$edit-text tiddler="$:/_opTaskStore" field="description" tag="input" default="" class='tc-edit-texteditor' placeholder='Brief descirption and Board title'/>

Map name: <$edit-text tiddler="$:/_opTaskStore" field="caption" tag="input" default={{$:/_opTaskStore!!taskname}} class='tc-edit-texteditor' placeholder='Task name as will appear on map'/>

Asigned to: <$edit-text tiddler="$:/_opTaskStore" field="assignedto" tag="input" default="" class='tc-edit-texteditor' placeholder='no-one'/>

<$button>New Task

<$action-createtiddler $basetitle={{$:/_opTaskStore!!taskname}} shorttext={{$:/_opTaskStore!!description}} tmap.id={{{ [[]make[%uuid%]] }}} assignedto={{$:/_opTaskStore!!assignedto}} caption={{$:/_opTaskStore!!caption}} />

<$action-deletetiddler $tiddler="$:/_opTaskStore"/>

</$button>

Watt

unread,
Jul 21, 2019, 3:39:07 PM7/21/19
to TiddlyWiki
Nice! A lot more concise.

Correct me if I'm wrong but I believe your optaskstore is a nice example of a state tiddler.
https://tiddlywiki.com/#StateMechanism

Good luck with the project.

MagoArcade

unread,
Jul 21, 2019, 3:54:37 PM7/21/19
to TiddlyWiki
Ha. I have no idea! It's just what dropped out of the bottom of 2 hours of fishing around and trial and error!

It did also solve my original problem too around storing the final used name into a field. Using one of the the same 'dummy' tiddler's fields to store it and read it back again did the trick. Relevant code:

<$action-createtiddler $basetitle={{$:/_opTaskStore!!taskname}} $savetitle="$:/_opTaskStore!!finalname" shorttext={{$:/_opTaskStore!!description}} tmap.id={{{ [[]make[%uuid%]] }}} assignedto={{$:/_opTaskStore!!assignedto}} caption={{$:/_opTaskStore!!caption}} tags="[[Task]]" color={{$:/_opTaskStore!!color}}/>


<$action-navigate $to={{$:/_opTaskStore!!finalname}}/>

Relevant part being

$savetitle="$:/_opTaskStore!!finalname"


Watt

unread,
Jul 21, 2019, 4:07:34 PM7/21/19
to TiddlyWiki
Congratulations, you've discovered state tiddlers. It took me years to discover state tiddlers. Careful or they'll ask you to write the documentation.
Reply all
Reply to author
Forward
0 new messages