Forum Discussion

DanielJohnson2's avatar
DanielJohnson2
Qrew Trainee
3 years ago

Jinja2 Pipelines question, so nothing if field is empty

Hi All,

I'm trying to get a pipelines email step to only show the text "Call Rating:" if the call rating field is not blank. I've tried:

{% if c.call_rating != '' %}
Call Rating: {{c.call_rating}}
{% else %}
''
{% endif %}​

and

{% if c.call_rating is defined %}
Call Rating: {{c.call_rating}}
{% else %}
''
{% endif %}

But the resulting email from both of those when that field is blank still says:

Call Rating:

Any idea how to get it so that line doesn't show in the email if that field is blank?

Thanks,



------------------------------
Daniel Johnson
------------------------------

  • You can use the {{CLEAR}} code:

    {% if c.call_rating != '' %}
    Call Rating: {{c.call_rating}}
    {% else %}
    {{CLEAR}}
    {% endif %}​​

    {% if c.call_rating is defined %}
    Call Rating: {{c.call_rating}}
    {% else %}
    {{CLEAR}}
    {% endif %}

    Check out the documentation if you have the time, it's very helpful: https://help.quickbase.com/pipelines/transforming_data.html
    ------------------------------
    Sean Connaughton
    ------------------------------

    • DanielJohnson2's avatar
      DanielJohnson2
      Qrew Trainee
      Hey Sean,

      Thanks for the reply, but that didn't work. I still got "Call Rating:" in the email output with nothing after it.

      ------------------------------
      Daniel Johnson
      ------------------------------
      • DanielJohnson2's avatar
        DanielJohnson2
        Qrew Trainee
        I just tried:
        {% set rating = 'Call Rating: ' %}
        {% if c.call_rating is defined %}
        {{rating}}{{c.call_rating}}
        {% else %}
        {{CLEAR}}
        {% endif %}​
        and got the same result. The output email still  has "Call Rating:" with nothing after it.

        ------------------------------
        Daniel Johnson
        ------------------------------