HI All,
I am trying to set up a data entry screen that accepts various fields and creates a tiddler with a title created out of some of the supplied field values and a set of tags, also from various field values in addition to [[All Items]]
and [[Needs History]]
(see screen shot below)
All of this seems to work OK except for one value, the name of the state in which the item is housed.
A cut down test wiki can be accessed at http://cultconv.neocities.org/test.html
The problem occurs in the $:/TLS/Actions/Add New Item
tiddler, whose code is
Add the information for the new item below and press the //Add this item// button
The asset number for this new object will be {{{ [{$:/TLS/incremental}] }}}
State Code: <$select tiddler='$:/TLS/selectedstate' field='state-code'>
{{$:/TLS/state_for_select}}
</$select>
OS for overseas, PRI for private
<$reveal type="match" stateTitle="$:/TLS/selectedstate" stateField="state-code" text="-">
Error - the selected state code can not be '-'
</$reveal>
<$reveal type="nomatch" stateTitle="$:/TLS/selectedstate" stateField="state-code" text="-">
City/Town: <$edit-text tiddler="$:/TLS/city" tag="input"/>
Location: <$edit-text tiddler="$:/TLS/location" tag="input"/>
Type: <$edit-text tiddler="$:/TLS/type" tag="input" /> If unknown, enter 'type unknown'
-----
<$button>
<$let
selectedstatecode={{$:/TLS/selectedstate!!state-code}}
selectedstatename={{{ [<selectedstatecode>match[NT]then[Northern Territory]] }}}
selectedstatename={{{ [<selectedstatecode>match[WA]then[Western Australia]] }}}
selectedstatename={{{ [<selectedstatecode>match[SA]then[South Australia]] }}}
selectedstatename={{{ [<selectedstatecode>match[VIC]then[Victoria]] }}}
selectedstatename={{{ [<selectedstatecode>match[NSW]then[New South Wales]] }}}
selectedstatename={{{ [<selectedstatecode>match[QLD]then[Queensland]] }}}
selectedstatename={{{ [<selectedstatecode}>]match[TAS]then[Tasmania]] }}}
selectedstatename={{{ [<selectedstatecode>match[ACT]then[Australian Capital Territory]] }}}
selectedstatename={{{ [<selectedstatecode>match[PRI]then[Private]] }}}
selectedstatename={{{ [<selectedstatecode>match[OS]then[Overseas]] }}}
locationTag={{$:/TLS/location}}
typeTag={{$:/TLS/type}}
cityTag={{$:/TLS/city}}
>
<$action-createtiddler
$basetitle={{{ [{$:/TLS/incremental}addsuffix[:]addsuffix{<selectedstatename>}addsuffix[ - ]addsuffix{$:/TLS/type}addprefix{$:/TLS/selectedstate!!state-code}] }}}
tags={{{ [[All Items]] [[Needs History]] [<cityTag>] [<selectedstatename >] [<locationTag>] [<typeTag>] +[format:titlelist[]join[ ]] }}}
CityTown={{$:/TLS/city}}
Location={{$:/TLS/location}}
State=<<selectedstatename>>
GunType={{$:/TLS/type}}
$template="$:/TLS/CreateTemplateItems"
/>
<$action-navigate $to={{{ [{$:/TLS/incremental}addsuffix[:]addsuffix{$:/TLS/selectedstate!!state-name}addsuffix[ - ]addsuffix{$:/TLS/type}addprefix{$:/TLS/selectedstate!!state-code}] }}} />
<$action-setfield $tiddler="$:/TLS/dateofmanufacture" text=""/>
<$action-setfield $tiddler="$:/TLS/city" text=""/>
<$action-setfield $tiddler="$:/TLS/location" text=""/>
<$action-setfield $tiddler="$:/TLS/manufacturer" text=""/>
<$action-setfield $tiddler="$:/TLS/serialnumber" text=""/>
<$action-setfield $tiddler="$:/TLS/weightofprojectile" text=""/>
<$action-setfield $tiddler="$:/TLS/range" text=""/>
<$action-setfield $tiddler="$:/TLS/caption" text=""/>
<$action-setfield $tiddler="$:/TLS/imageURL" text=""/>
<$action-setfield $tiddler="$:/TLS/coordinates" text=""/>
<$action-setfield $tiddler="$:/TLS/calibre" text=""/>
<$action-setfield $tiddler="$:/TLS/type" text=""/>
<$action-setfield $tiddler="$:/TLS/selectedstate" $field="state-code" $value=""/>
<$action-setfield $tiddler="$:/TLS/selectedstate" $field="state-name" $value=""/>
<$action-setfield $tiddler="$:/TLS/incremental" text={{{ [{$:/TLS/incremental}add[1]] }}}/>
</$let>
Add new Item
</$button>
</$reveal>
The area I think the problem is in is the $let
statement
<$let
selectedstatecode={{$:/TLS/selectedstate!!state-code}}
selectedstatename={{{ [<selectedstatecode>match[NT]then[Northern Territory]] }}}
selectedstatename={{{ [<selectedstatecode>match[WA]then[Western Australia]] }}}
selectedstatename={{{ [<selectedstatecode>match[SA]then[South Australia]] }}}
selectedstatename={{{ [<selectedstatecode>match[VIC]then[Victoria]] }}}
selectedstatename={{{ [<selectedstatecode>match[NSW]then[New South Wales]] }}}
selectedstatename={{{ [<selectedstatecode>match[QLD]then[Queensland]] }}}
selectedstatename={{{ [<selectedstatecode>]match[TAS]then[Tasmania]] }}}
selectedstatename={{{ [<selectedstatecode>match[ACT]then[Australian Capital Territory]] }}}
selectedstatename={{{ [<selectedstatecode>match[PRI]then[Private]] }}}
selectedstatename={{{ [<selectedstatecode>match[OS]then[Overseas]] }}}
locationTag={{$:/TLS/location}}
typeTag={{$:/TLS/type}}
cityTag={{$:/TLS/city}}
>
It would appear that the variable, selectedstatename
, is not being set by any of these assignment statements.
@CasperBooWisdom suggested the form of the statements to set selectedstatename
as this is a simpler form of the table lookup I have been trying, which also did not work.
As you can see from the attached, if I enter statecode, town,location and type, a tiddler with the title as shown is created which misses the tag, South Australia and also has an empty state field. The state name is also missing in the title.
Interestingly, the other tags and their variables are correctly created.
The only difference that I can see is that all except for selectedstatename are provided through the entry screen whilst the selectedstatename is assigned according to the value of the statecode in the entry screen.
I have tried replacing the assigment lines to the form, replacing selectedstatecode by $:/TLS/selectedstate!!state-code
selectedstatename={{{ [{$:/TLS/selectedstate!!state-code}match[NT]then[Northern Territory]] }}}
This also does not work.
@pmario suggested moving the button action code into a procedure which I tried but it also did not work.
Loging variables indicates that selectedstatename is never updated.
I am hoping someone can tell me what I am doing wrong.
bobj