Forum Discussion

JeremyAnson's avatar
JeremyAnson
Qrew Cadet
3 years ago

Pipeline error when date field is empty and using {{datefield|date_dmy}} to format date

I have a pipeline that takes several date fields and writes them out to text fields in another table, with {{datefield|date_dmy}} used to format the date. It works when all the date fields contain a date, but fails when any of the fields are empty, producing an error 'Validation error: Incorrect template'. 

Has anyone else had the same issue and/or know how to workaround this without adding in conditions to check for fields being blank (as this isn't a feasible solution) or creating formula fields in the table to format the dates as strings? 

Thanks.

------------------------------
Jeremy Anson
------------------------------

2 Replies

  • Something like this should do the trick

    {{'' if a.datefield is none eles a.datefield|date_dmy}}
     
    If you're interested in learning more about Jinja check out this Intro to Jinja for Pipelines course.


    ------------------------------
    Quick Base Junkie
    ------------------------------
    • JeremyAnson's avatar
      JeremyAnson
      Qrew Cadet
      Thanks for the advice - much appreciated!

      I managed to get there with {% if not a.datefield is none %}{{ a.datefield|date_dmy}}{% endif %}

      ------------------------------
      Jeremy Anson
      ------------------------------