Filling the field with multiple values from json

67 views
Skip to first unread message

Darek Bobak

unread,
Sep 30, 2020, 7:17:07 AM9/30/20
to TiddlyWiki
Why it doesn't work? 

I'd like to:
1. Get the value from the multivalue json property (culture in this case)
2. Assign all of the values to the field "cultures" of other tiddler

The value (marked red below) is displayed properly, but only the lat value is assigned to field. I'm attaching sample json file, from which I try to get the data.

\define totext() <$text text="""$(cult_field_val)$"""/>

<$button>
Fill the cultures field
  <$list filter="[all[tiddlers]tag[+tmp-data-site]]" >
  <$set name="site_tid" filter="[<currentTiddler>removesuffix[.geojson]]" >
  <$set name="cult_field_cur" value=<<cult_field_val>> emptyValue="">
    <$list variable="cult-path" filter="[<currentTiddler>indexes[/features/0/properties/cultures]addprefix[/features/0/properties/cultures/]]" >
      <$wikify name="cult-path-w" text=<<cult-path>> >
        <$set name="cult_field_val" filter="[<currentTiddler>getindex<cult-path>addprefix<cult_field_cur>]" >
          <$set name="cult_list" value=<<totext>> >
          <$wikify name="cult_list_w" text=<<cult_list>> >
          <<cult_list_w>>
          <$action-setfield $tiddler=<<site_tid>> $field="cultures" $value=<<cult_list_w>> />
          </$wikify>
          </$set>
        </$set>
      </$wikify>
    </$list>
  </$set>
  </$set>
  </$list>
</$button>

cheers,
Darek


Biśnik.geojson.json

Darek Bobak

unread,
Sep 30, 2020, 1:02:54 PM9/30/20
to TiddlyWiki
Ok, I see what was wrong. Each culture was generated in the separate list cycle and written to the field, overwriting it.
This is corrected, working code:

<$button>
Uzupełnij tagi kultur
  <$list filter="[all[tiddlers]tag[+tmp-data-site]]" >
  <$set name="site_tid" filter="[<currentTiddler>removesuffix[.geojson]]" >
    <$list variable="cult-path" filter="[<currentTiddler>indexes[/features/0/properties/cultures]addprefix[/features/0/properties/cultures/]]" >
      <$wikify name="cult-path-w" text=<<cult-path>> >
        <$action-listops $tiddler=<<site_tid>> $field="cultures" $subfilter="[<currentTiddler>getindex<cult-path>]" />
      </$wikify>
    </$list>
  </$set>
  </$list>
</$button>

Darek Bobak

unread,
Sep 30, 2020, 1:34:25 PM9/30/20
to TiddlyWiki
And another correction, in case you have a spaces in tiddler's names:

<$button>
Uzupełnij tagi kultur
<$list filter="[all[tiddlers]tag[+tmp-data-site]]" >
<$set name="site_tid" filter="[<currentTiddler>removesuffix[.geojson]]" >
<$wikify name="site_tid_w" text=<<site_tid>> >
<$action-listops $tiddler=<<site_tid_w>> $field="cultures" $filter="[[]]" />
<$list variable="cult-path" filter="[<currentTiddler>indexes[/features/0/properties/cultures]addprefix[/features/0/properties/cultures/]]" >
<$wikify name="cult-path-w" text=<<cult-path>> >
<$action-listops $tiddler=<<site_tid_w>> $field="cultures" $subfilter="[<currentTiddler>getindex<cult-path>]" />
</$wikify>
</$list>
</$wikify>
</$set>
</$list>
</$button>

Joshua Fontany

unread,
Sep 30, 2020, 7:37:00 PM9/30/20
to TiddlyWiki
Well done!

Best,
Joshua Fotnany
Reply all
Reply to author
Forward
0 new messages