Skip to main content
Question

Pipeline Jinja Issues

  • March 13, 2023
  • 0 replies
  • 368 views

DwightMunson1
Forum|alt.badge.img+8

Hello Quickbase Community!

I'm having issues with a pipeline. 

Step A: Quickbase Channel - Quickbase API - Make a Request

Essentially, I query data in a table and get back some JSON data. This step works completely fine. 

Step B (the problem step): Quickbase Channel - Quickbase API - Make a Request

This request is to post data to a test table for now. I'm trying to run a for loop on the data. I'm eventually going to incorporate the myTimeStop variable, but it can be ignored for now. I'm trying to iterate through the data, adding a line for each one, and keeping a running total for row '33'.

This works, but it's still resetting the runningTotal to 0.0 in each loop for some reason. Table ID redacted.

{% set myDataSet = "myTableID" %}
{% set myTimeStop = 5.0 | float %}
{% set runningTotal = 0.0 | float %}
{
    "to": "{{myDataSet}}",
    "data": [
        {% for row in a.json.data %}
        {% set runningTotal = runningTotal + row['33'].value %}
        {
            "6": {
                "value": "{{row['36'].value}}"
            },
            "7": {
                "value": "{{row['8'].value}}"
            },
            "8": {
                "value": "{{row['13'].value}}"
            },
            "9": {
                "value": "{{row['33'].value}}"
            },
            "10": {
                "value": "{{runningTotal}}"
            }
        }
        {% if not loop.last %},{% endif %}
        {% endfor %}
    ]
}

I've tried this, but it gives me a vague error. It's pretty much the same as the top, but I'm appending each line to the list as later I want to iterate through the data until I hit the timestop variable and then add that list to Quickbase. 

{% set myDataSet = "myTableID" %}

{% set myTimeStop = 5.0 | float %}
{% set runningTotal = 0.0 | float %}

{% set data = [] %}

{% for row in a.json.data %}
    {% set runningTotal = runningTotal + row['33'].value %}
    {% set item = {
        "6": {"value": row['36'].value},
        "7": {"value": row['8'].value},
        "8": {"value": row['13'].value},
        "9": {"value": row['33'].value},
        "10": {"value": runningTotal}
    } %}
    {% do data.append(item) %}
{% endfor %}

{
    "to": "{{myDataSet}}",
    "data": {{data|to_json}}
}

I'm just not understanding why it doesn't like the second variation. It passes the test initially, but when run gives a vague "Something went wrong executing a step. Try modifying your pipeline."

Also, not understanding why in the first one it's not actually keeping a running total. 



------------------------------
Dwight Munson
------------------------------
This topic has been closed for replies.

DwightMunson1
Forum|alt.badge.img+8
  • Author
  • Registered
  • March 13, 2023

For the second bit, I've also tried:
{% set data = data.append(item) %}

and

{% set _ = data.append(item) %}

and

{{data.append(item)}}

I've also tried: 

{
    "to": "{{myDataSet}}",
    "data": {{data|tojson}}
}

and

{
    "to": "{{myDataSet}}",
    "data": {{ data | tojson }}
}



------------------------------
Dwight Munson
------------------------------