Forum Discussion

AmyGosz1's avatar
AmyGosz1
Qrew Trainee
2 years ago

Pipeline code using 'or' and 'and'

We need to populate a 'month' field if family member 1 or family member 2 has a birthday that month. Each month has its own field. In this example, I am using the MAY TOUCH field. So, if (family member 1 or family member 2 has a May birthday) and MAY TOUCH is blank, add the value 'Birthday Month' to MAY TOUCH. However, I get the red box around that field which means something isn't right. I have scoured this forum and can't seem to figure out what part of the code is wrong. I have tried many different words like isNull, ="", and using quotes around "Birthday Month", etc, but none of those work. Here is my code:

{% if (a.account_number_family_1_birth_month_3_charac is May or a.account_number_family_2_birth_month_3_charac is May) and a.may_touch is not defined %}
Birthday Month
{% endif %}

The second part of this will be....if MAY TOUCH is defined, then MAY TOUCH value will have 'Birthday Month' appended to the text already in the field.

Step A in the Pipeline is Search Records where account_number_family_1_birth_month_3_charac does not equal 'blank' or account_number_family_2_birth_month_3_charac does not equal 'blank',
step B is Update Record

------------------------------
Amy Gosz
------------------------------

17 Replies

  • DonLarson's avatar
    DonLarson
    Qrew Commander
    Amy,

    I am not a Jinja guru.  @Prashant Maheshwari  @Doug Henning are the kings of this.   However I think your expression has the wrong operator and the text value needs quotes.

    a.account_number_family_1_birth_month_3_charac == 'May'



    ------------------------------
    Don Larson
    ------------------------------
    • AmyGosz1's avatar
      AmyGosz1
      Qrew Trainee
      == is a comparison operator to compare two objects so I don't thnk it would be used in this case.

      ------------------------------
      Amy Gosz
      ------------------------------
      • DonLarson's avatar
        DonLarson
        Qrew Commander
        Amy,

        I looked at this again and may have a non Jinja solution for you.

        FID 111 is a Date
        FID 112 is a Date
        FID 113 is a Text 


        # Character Date Search
        #

        # Account slugs:
        # - quickbase[XXXX]: Pipeline Token <None>
        ---
        - META:
        name: Character Date Search
        - QUERY quickbase[XXXXX] record search -> a:
        inputs-meta:
        export_fields: '"Touch, OneCharacter, TwoCharacter" <113, 111, 112>'
        query: ({111.EX.'May'}OR{112.EX.'May'})AND{113.EX.''}
        table: '"Parents: Parent" <bp4igy3re>'
        - a<>LOOP:
        - DO:
        - a<>ACTION quickbase record update -> b:
        inputs:
        touch: May
        ...



        ------------------------------
        Don Larson
        ------------------------------
  • PrashantMaheshw's avatar
    PrashantMaheshw
    Qrew Assistant Captain

    • Are we implying there are 12 fields for each month Jan /Feb / March and whenever a family member has a birthday , that particular field will get updated each month ? 
    • All items are stored as text ? Can you give example of one field to gauge ? 
    • I keep thinking why won't a QuickBase formula achieve this?
    I did a simple test with 
    
    (text)Name - Prashant
    (date)DOB - 29/05/1985
    (text)Month
    
    pipeline Jinja
    {{(a.dob|timezone('Asia/Calcutta')).strftime('%b')}}
    
    The advantage of above method is simply referencing the date field and month will be found. Once we are clear with the structure , we could play around



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

    • AmyGosz1's avatar
      AmyGosz1
      Qrew Trainee

      Yes, there is one field for each month. These fields are used as prompts for what type of contact may be needed. We do not capture full dates for the birthday and in many cases only know the month. If there is already text in the month field, then we don't want to overwrite that, only add on additional note about it being a birthday month. If there is no text, then we will just populate it noting that it is a birthday month.

      12 Month fields - text, multiple lines

      3 charac Month field - text

      Family Member 1 and 2 fields - text

      I am trying to figure out how the pipeline can check for values in the month field and if no value, populate with 'Birthday Month'. If there is a value, then keep current value and add 'Birthday Month'.



      ------------------------------
      Amy Gosz
      ------------------------------
      • DougHenning1's avatar
        DougHenning1
        Community Manager

        Don's original reply is correct, you need to use == for the comparison and put quotes around the value to compare.  This will add to the may_touch field if a value exists, or set it to "Birthday Month" if empty.

        {%- if (a.account_number_family_1_birth_month_3_charac == "May" or a.account_number_family_2_birth_month_3_charac == "May") and not a.may_touch %}
        Birthday Month
        {% else %}
        {{ a.may_touch }}
        Birthday Month
        {%- endif %}



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