Populate field upon saving tiddler

75 views
Skip to first unread message

switchplayer

unread,
Feb 19, 2021, 11:51:05 PM2/19/21
to TiddlyWiki
Hello, 

I am wanting to find a way to have a field populated/updated each time I save the tiddler. This field should take values from two other fields. 

Simple example:

(Field 1) First Name: DA
(Field 2) Last Name: Carson

(Field 3) Full Name: DA Carson


I want Field 3 to be populated with the values from Field 1 and Field 2 each time the tiddler is saved.

Definitely appreciate any input here...still a newbie with TiddlyWiki!




Michael Wiktowy

unread,
Feb 20, 2021, 8:45:11 AM2/20/21
to TiddlyWiki
You might consider just using transclusion or macros rather than store duplicative information.

You can then just use something like {{!!firstname}} {{!!lastname}} or <<fullname>> where you need to.

You might be able to do what you want to do by hooking action widgets into a separate button or the system/tiddler save button but it might end up being an awkward and error-prone way of doing things.

/Mike

amreus

unread,
Feb 20, 2021, 9:06:19 AM2/20/21
to TiddlyWiki
Mike has the right idea.

Here is a link to an example that shows one possible use case:


* If tiddlers that are tagged "Person" have 2 fields: "first-name" and "last-name".
* The View Template tiddler displays the full name in any tiddler tagged "Person"

switchplayer

unread,
Feb 20, 2021, 4:05:48 PM2/20/21
to TiddlyWiki
Thank you all for the responses. 

I am not certain transclusion will work for what I am wanting to accomplish. Below is additional detail around what I am needing to use this for:

I have two fields for each tiddler. The first field is Bucket, which is intended to capture the high level bucket that the tiddler falls under in my life. The second field is Primary Topic, which is intended to capture the main topic the tiddler falls under. 

To (hopefully) give a simple example of this, suppose I have three tiddlers. 

Tiddler1 talks about the definition of prayer.
Tiddler2 gives an example of a short prayer that we can pray today.
Tiddler3 talks about Matthew 6 and how Jesus taught his disciples how to pray.

Two buckets I have are "Theology" (notes pertaining to the academic/objective field of Theology) and "My Christian Life" (notes that are applicable to my personal spiritual life).

In the three tiddlers above, I would have the following values in the two fields:

Tiddler1 would have "Theology" in the Bucket field, and "Prayer" in the Primary Topic field.
Tiddler2 would have "My Christian Life" in the Bucket field, and "Prayer" in the Primary Topic field, as I can use this example in my prayer life.
Tiddler3 would have BOTH "Theology" and "My Christian Life" in the Bucket field, and "Prayer" in the Primary Topic field, as this pertains to a biblical commentary on Matthew 6 while also providing an example of prayer I can use in my personal prayer life. 

What I want is an additional field that automatically concatenates the Bucket values with the Primary Topic values. 

In the examples above, this additional field would have "Theology-Prayer" for Tiddler1, "My Christian Life-Prayer" for Tiddler2, and "Theology-Prayer,My Christian Life-Prayer" for Tiddler3

*If it helps, I have a background in Salesforce and this concept is somewhat similar to how Salesforce does many-to-many relationships. 

Soren Bjornstad

unread,
Feb 20, 2021, 4:23:09 PM2/20/21
to TiddlyWiki
I think the big question here is, how are you trying to use the contents of this hypothetical third field? If it's for display on a template, for instance, you could do something like...

<$list filter={{!!bucket}}>
  <<currentTiddler>>-{{!!primarytopic}}
</$list>

...which would display each bucket along with the primary topic. You could use a second $list if there can also be multiple primary topics (but presumably the name suggests there can't be).

If you're trying to search based on the bucket and primary topic, you probably shouldn't be doing this in the first place, as you can easily apply criteria to multiple fields using a filter anyway.

I can't think of a situation where one of these methods wouldn't work, but there might well be one. But without further information on your use case, it's going to be hard to figure out the best way to do it.
Reply all
Reply to author
Forward
0 new messages