I am trying to do something very simple, implement a look up table so that when the user enters the code for a state, eg. SA, the look up table finds the correct label, South Australia.
I have created a tiddler for each record in the lookup table, with two fields, the code and the name.
The problem is that in my code, although the state code is correctly updated through the code, the name of the state is not.
State Code: <$select tiddler='$:/TLS/selectedstate' field='state-code'>
{{$:/TLS/state_for_select}}
</$select>
-----
<$button>
<$set name="selectedstatecode" value={{$:/TLS/selectedstate!!state-code}} >
<$list filter="[all[tiddlers]field:statecode<selectedstatecode>]">
<$set name="selectedstatename" value={{!!statename}} >
<$action-setfield $tiddler="$:/TLS/selectedstate" $field="state-name" $value={{!!statename}} />
</$list>
<$set name="stateTag" value={{$:/TLS/selectedstate!!state-name}}>
<$set name="locationTag" value={{$:/TLS/location}}>
<$set name="typeTag" value={{$:/TLS/type}} >
<$set name="cityTag" value={{$:/TLS/city}} >
<$action-createtiddler
$basetitle={{{ [{$:/TLS/incremental}addsuffix[:]addsuffix{$:/TLS/selectedstate!!state-name}addsuffix[ - ]addsuffix{$:/TLS/type}addprefix{$:/TLS/selectedstate!!state-code}] }}}
tags={{{ [[All Items]] [[Needs History]] [<cityTag>] [<stateTag>] [<locationTag>] [<typeTag>] +[format:titlelist[]join[ ]] }}}
So if I select the state code SA, as you can see from the image, the selectedstate!!state-name field is not correctly updated.
After the first $set, the selectedstatecode variable is ‘SA’
After the $list, currentTiddler points to the $:/TLS/State/SouthAustralia tiddler.
After the second <$set statement, selectedstatename variable is set to South Australia
After the <$action-setfield statement, the field state-name of the tiddler $:/TLS/selectedstate is not set to South Australia
I can not explain this but I am obviously doing something wrong.
I have tried using the variable selectedstatename, which is correctly set to South Australia, in the action-setfield statement, but this still does not update the tiddler field.
Note the two different spellings statename and state-name, they are different fields in different tiddlers
Could someone point out my mistake please.
bobj