Forum Discussion

EdwardHefter's avatar
EdwardHefter
Qrew Cadet
3 years ago

Help using Multiselect fields in a pipeline with more than one item selected

I have a multi-select field called [food] that can have any or all values of things like peas, corn, bread, pasta, chicken, etc. I want to run a pipeline that copies records from a template table into the today's menu table. I am using a search records step that has {23.HAS.{{a.food}}} in it. Field 23 is the field to match in the template table and it has only one value in it (like peas, or corn, or bread). It is now a text field, but I can change it to a different kind of field if it helps.

The search works great when there is only one value in {{a.food}}, but if I have multiple values (like peas;corn), it fails because there is nothing in the template table that has peas AND corn in it.

How can I find all the records in the template table where field 23 matches ANY of the entries in {{a.food}}? On a whim, I tried doing the query backwards {{{a.food}}.HAS.23}, but that failed even when field 23 was a mutli-select field.

------------------------------
Edward Hefter
------------------------------

4 Replies

  • Challenge Accepted!

    This seems to do the trick.

    1. "set" the multi-select field into a Jinja list using the 'split' variable on the semicolon
    2. Iterate on the list using the "for" statement to create the advanced query expression
    3. Use "if" and "loop.last" to avoid adding an 'OR' at the end of the query

    To learn more about using Jinja in Pipelines, I have created a course called Intro to Jinja for Pipelines.

    {% set list = a.food.split(';') %}
    {% for item in list %}
    {% if loop.last %}{23.HAS.'{{item}}'}
    {% else %}
    {23.HAS.'{{item}}'}OR{% endif %}
    {% endfor %}​


    ------------------------------
    Quick Base Junkie
    ------------------------------

      • Quick_BaseJunki's avatar
        Quick_BaseJunki
        Qrew Captain
        Awesome!

        Thanks for letting me know 🥳

        ------------------------------
        Quick Base Junkie
        ------------------------------
    • EricHaseltine1's avatar
      EricHaseltine1
      Qrew Member
      This worked perfectly for me as well.

      I had to change from HAS to EX, but otherwise exactly what I needed.

      Thanks!

      ------------------------------
      Eric Haseltine
      GrantWorks
      ------------------------------