How to fill parameter of procedure with field value?

Hello TW-Community,

I am using a procedure with parameters but I am struggling with standard value of a parameter read from a field of a separate tiddler.

Here is my procedure what is called with selector and fields like <<edit_fields "Location" "caption Name Country Zip City">> and is working well, so far.

code-body: yes
tags: $:/tags/Global
title: proc/edit_fields

\whitespace trim
\procedure edit_fields(selector, fields)
<$let
	config=<<currentTiddler>>
>

Please enter the data for the &nbsp; <<selector>> &nbsp;:&nbsp; {{!!caption}}.<br>
The origin name of this Data set is:  &nbsp; <<config>>.<br>
<hr>
<table>
	<$list filter="[enlist<fields>]" variable="field">
	<tr>
		<th><<field>></th>
		<td>
			<$select field=<<field>> default=<<field>> >
				<option value="">(any)</option>
				<$list filter="[tag<selector>sort[caption]get<field>] [tag<field>get[caption]sort[]]+[unique[]]" variable="value">
					<option><<value>></option>
				</$list>
			</$select>
		</td>
		<td>
		 <$edit-text tiddler=<<field_of_field>> field=<<field>>/>
		</td>
		<td>
         <$list filter="[tag<field>count[]]" variable="c_of_field">
           <%if [<c_of_field>compare:number:gt[0]] %>
            <$transclude $variable="new-entry" selector=<<field>> sep="/" />
           <% endif %>
         </$list>
		</td>
	</tr>
	</$list>
</table>
<hr>
</$let>
\end

Parallel I have a Tiddler containing the information about the fields for the selectors:

Asset: caption Name Department Location
Department: caption Name Location
Location: caption Name Country Zip City
tags: $:/tags/Global
title: info/db-tables

How to modify the head of the procedure to read out the fields form the info/db-tables if there is nothing in the call like <<edit_fields "Location" "">>.
I tried the following but without success.
\procedure edit_fields(selector, fields:{{info/db-tables!!<<selector>>}})

Thank you for any support and help
Stefan

Use wikitext code to set the default fields value if none is provided, like this:

\procedure edit_fields(selector, fields)
<$let fields={{{ [<fields>!match[]] ~[[info/db]getindex<selector>] }}}>

-e

Hi @EricShulman,

thank you for the quick support.
It didn’t work immediately as I had hoped, but I was able to correct it myself.

\procedure edit_fields(selector, fields)
<$let 
    fields={{{ [<fields>!match[]] ~[[info/db-tables]get<selector>] }}}
>

Stefan