Skip to main content
Question

(Video) How to generate children from simple text field using Jinja

  • November 29, 2022
  • 0 replies
  • 240 views

Forum|alt.badge.img+11
I've been using below methodology at LOT for quickly capturing info on the go on mobile , this is also used by my assistant for quick capturing information in 1 place during meetings. 

Why am I posting this ? Barely any information exists on JINJA on forums and online from pipeline perspective. 

PS : This is a Version 1 video , I do skip through explanation of jinja code thoroughly , if people demand , version 2 would be created 

Jinja - Generated Children through text fields
Loom remove preview
Jinja - Generated Children through text fields
View this on Loom >



------------------------------
Prashant Maheshwari
------------------------------

MarkShnierYou
Forum|alt.badge.img+22
  • Quickbase Alumni
  • November 29, 2022
Thx for posting!

------------------------------
Mark Shnier (Your Quickbase Coach)
mark.shnier@gmail.com
------------------------------

  • Quickbase Alumni
  • November 29, 2022
Very interesting! Thanks for posting!

------------------------------
Forrest Parker
------------------------------

Forum|alt.badge.img+6
  • Quickbase Staff
  • November 29, 2022
Thank you for making the video and sharing your knowledge with others!  For the sake of learning, I'd like share some improvements you can make to the Jinja for more streamlined code. 

1. Try not to use variables that are also the names of filters (list is a filter). While it will work most of the time, it can cause confusion.

2. The namespace functionality is very useful, but in your case you don't actually need it.  I assume you're using it because some lines may be blank and you don't want to count them.  If you filter the list to exclude the blank lines then you can just use the loop index instead:
{% for x in plist if x|trim != '' -%}​


3. Use the variable specified in the for loop (x) instead of list[loop.index0]

4. You can use loop.last to see if you need to add the comma:

{{ ',' if not loop.last }}

Here's the complete updated code:
{% set plist = a.quick_capture.split('\n') -%}
{
  "to": "br8hpcpk7",
  "data": [
    {% for x in plist if x|trim != '' -%}
      {
        "18": { "value": "{{a.related_director}}" },
        "89": { "value": "{{a.id}}" },
        "6": { "value": "{{loop.index}} {{ x|trim }}" }
      }{{ ',' if not loop.last }}
    {% endfor -%}
  ]
}


Thanks again for sharing and hope this helps!



------------------------------
Doug Henning
------------------------------

Forum|alt.badge.img+15
  • Quickbase Alumni
  • November 30, 2022
First, thank you.  The concept of a "Quick Capture" is going to be helpful with many business cases.

Second, I am going to have to watch this several times and then come back to you with questions.


------------------------------
Don Larson
------------------------------

Forum|alt.badge.img+15
  • Quickbase Alumni
  • December 1, 2022
Prashant,

Where did you start you Jinja education?   I have been using what QB has published and a smattering of help from the Community.


Having gone through what you and Doug have posted, it is clear I am way behind both of you.

------------------------------
Don Larson
------------------------------