Forum Discussion

LB's avatar
LB
Qrew Cadet
5 months ago

Change Logs

Hello, 

I'm attempting to create a change log to show the previous and new result changes from 3 tables into a "change log" table. I'm missing something with setting up the relationships I think and setting up the pipeline to pull in all fields at the same time regardless if all of them have a change...I attempted to also use the formula given in this training to color code the fields that have changes and it does not work. 

And I also referenced this material https://community.quickbase.com/discussions/quickbase-discussions/creating-data-change-logs-using-pipelines/84044

 

 

  • Probably best to just work on one table, and once you have it working repeat the steps for the other tables. Also, get the basic steps working first (Relationship correct, and Pipeline firing and filling in fields) first, and then worry about color coding, etc. For the community to help troubleshoot, I would first explain:

    1. What relationship do you have currently with your main table and log table? 
    2. What exact issue are you running into with your Pipeline (is it even firing? is it not filling out the fields correctly?)? 

    The more details the better to receive help, as right now all we know is 'it isnt working'.

    • LB's avatar
      LB
      Qrew Cadet

      I've set up and repeated the pipeline steps for each table, but when I run the pipeline it's not pulling in all of the fields in my change log table; for example it's not showing the current info in the Prev fields if there was no changes in that field, it's only showing the new field info. I would like for it to show the current info along with the new and info and highlight only what is new. 

      I have 3 tables

      People (parent table)

      Placement (child table)

      Update (child table to placement)

      The change log table has a many relationship back to those tables

  • So is the setup this:

    In the change log table you have for example:
    [Field A Old], [Field A New], [Field B Old], [Field B New], etc?

    and each time there is a change, the old an new are supposed to fill in, but if the old and new are the same value, only the new fills in? Is that the current issue?

    • LB's avatar
      LB
      Qrew Cadet

      Yes, that's how I have it set up, with old and new

      and yes, that is the issue only the new is filling in and not the old value in addition

      • MikeTamoush's avatar
        MikeTamoush
        Qrew Commander

        Someone else might have better ideas, but I can think of 2.

        You could make a formula field for the Old in the change log, which says if Old=blank, then show new. That would be more of the reactive solution. The proactive one would be to use jinja to set the field.

        I'm assuming the old field is set with {{a.$prev.fieldA}}

        I am not great with jinja so hopefully someone else can jump in, but my notes show:

        {{ CLEAR if a.date is none else a.date }} //To clear a date using condensed code

        So perhaps for you: {{a.FieldA if a.$prev.FieldA is none else a.$prev.FieldA}}

        I've never tried that but maybe it will work. Here are my other notes on if/then in jinja:

        //Below is general if/else in Pipelines with jinja.

        {% if some_condition %} {{do something }}
        {% elif some_other_condition %} {{do something }}
        {% else %} {{do something }}
        {% endif %}

        Example:

        {% if a.date is none %} {{ CLEAR }}
        {% else %} {{a.date}}
        {% endif %}