Skip to main content
Question

Jinjia question

  • September 22, 2023
  • 0 replies
  • 89 views

Forum|alt.badge.img+6

Hi, I am not familiar with Jinjia.  I am trying to generate several child records by using Pipeline. The 1st child will get a date "9/21/2023", 2nd one will get "9/22/2023", and so on.  However, it always give the value "9/21/2023" for all the children.  This is my Jinjia code:

{
    "to": "btib9aemmh",
    "data": [
        {% set adate=time.today%}
        {% for num in range(5) %}
        {% set adate=adate+time.delta(days=1)%}  

        {
            "7": {
                "value": "{{a.id}}"
            },
            "18": {
            "value": "{{adate|date_ymd}}"
            }
        }
        {% if loop.last == false %},
        {% endif %}
       
        {% endfor %}
    ]
}

Thanks in advance!



------------------------------
Hongkun liang
------------------------------
This topic has been closed for replies.

Forum|alt.badge.img+11

You are not incrementing the adate counter , try below

{% set adate = adate + time.delta(days=num) %}

Optional
time.today will generate date at utc time . Using time zone help , I generally do 

{{ (time.now|timezone('Asia/Calcutta'))|date_ymd('-') }}

Hope this helps.


All thanks @Quick Base Junkie for awesome jinja training



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


MarceloBenavide
Forum|alt.badge.img+8

Hi, this code is based in your original code, this work for me:

{
    "to": "btk9drq7t",
    "data": [        
        {% for num in range(5) %}        
        {% set adate=time.today+time.delta(days=num+1)%}  
        {        
            "6": {
            "value": "{{adate|date_ymd}}"
            }
        }
        {% if loop.last == false %},
        {% endif %}
       
        {% endfor %}
    ]
}

Thank you

Marcelo Benavides Torres



------------------------------
Marcelo Benavides
------------------------------

Forum|alt.badge.img+6
  • Author
  • Registered
  • September 23, 2023

Just give a quick update.

By using namespace function as Prashant 's instruction, I am able to calculate each total within each cycle and assign the value to the child table.  Thanks again for Prashant's post.



------------------------------
Hongkun liang
------------------------------