Getting value of dynamically named field into parameter

59 views
Skip to first unread message

Stobot

unread,
Nov 5, 2017, 11:17:26 AM11/5/17
to TiddlyWiki
Hello everyone,

I'm building a mini-utility for myself as I redesign my project management system. I'm trying to allow the user to enter an 'old' field name and 'new' field name, and then provide buttons to make the changes. Eventually to be a single button, but in two steps until I figure it out...

The below works only because I'm hard-coding the name of the 'old' field value as 'context' (current value of $:/temp/fieldchanger/from) in the 4th code line below. 

Short version: I essentially need the equivalent of {{!!{{$:/temp/fieldchanger/from}}}} to work, and know it must be a combination of <$set> and macros, but I can't figure it out and have been trying for hours.

Change from: <$edit-text tiddler="$:/temp/fieldchanger/from" tag="input" default=""/> Change to: <$edit-text tiddler="$:/temp/fieldchanger/to" tag="input" default=""/>

Step 1: <$button>Add New Field
<$list filter="[has{$:/temp/fieldchanger/from}]">
<$action-setfield $field={{$:/temp/fieldchanger/to}} $value={{!!context}}/>
</$list>
</
$button>
| Step 2: <$button>Delete Old Field
<$list filter="[has{$:/temp/fieldchanger/from}]">
<$action-deletefield $field={{$:/temp/fieldchanger/from}}/>
</$list>
</
$button>

<table>
<th>Title</th><th>{{$:/temp/fieldchanger/from}}</th><th>{{$:/temp/fieldchanger/to}}</th>
<$list filter="[has{$:/temp/fieldchanger/from}]">
<tr>
<td><$link><$view field="title"/></$link></td>
<td><$transclude field={{$:/temp/fieldchanger/from}}/></td>
<td><$transclude field={{$:/temp/fieldchanger/to}}/></td>
</tr>
</
$list>
</table>

Hoping someone can help! I've learned a lot about what 'wikifies' and what doesn't (macrocall vs <<>> for example), but can't seem to apply that knowledge into a parameter where my only option would be <<>> notation. 

Mark S.

unread,
Nov 5, 2017, 12:35:07 PM11/5/17
to TiddlyWiki
This happens to be close to something I'm interested in at the moment. Here's what seems to work for step 1:

\define oldfield() {{!!$(from)$}}

Change from: <$edit-text tiddler="$:/temp/fieldchanger/from" tag="input" default=""/> <br/>

Change to: <$edit-text tiddler="$:/temp/fieldchanger/to" tag="input" default=""/>

<$set name="from" value={{$:/temp/fieldchanger/from}} >

Step 1: <$button>Add New Field
<$list filter="[has{$:/temp/fieldchanger/from}]">
<$wikify name=oldvalue text="<<oldfield>>">
<$action-setfield $field={{$:/temp/fieldchanger/to}} $value=<<oldvalue>>/>
</
$wikify>
</$list>
</
$button>
</$set>

I used a macro to concatenate the field and the {{!!...}} structure, and then used the <$wikify> widget to render the result. I can't imagine how this was done before the Wikify widget.

Good luck!
Mark

Stobot

unread,
Nov 5, 2017, 1:28:43 PM11/5/17
to TiddlyWiki
That's perfect Mark - the wikify was the missing piece from what I had tried. I completely misunderstood what that widget did - I come across a problem like this all the time and now know what to use. Thanks for the reply!!
Reply all
Reply to author
Forward
0 new messages