Forum Discussion

NickCharalambou's avatar
NickCharalambou
Qrew Cadet
2 months ago

Pipelines and appending / joining

I have a jinja expression that simply compares old to new, and writes to the text field it sits in on the pipeline:

{% set result = "" %}
{% if a.requested_offer_types != a.$prev.requested_offer_types %}
{% set result = result + "Requested Offer Types from " + a.$prev.requested_offer_types + " to " + a.requested_offer_types + "\n" %}
{% endif %}
{{ result }}

The if works however it overwrites the text field.  I want it to append to the text field.

I dont want to use the log function, as I dont need the user and time details

 

3 Replies

  • Thanks.  I will try that method out, as the method below continues to throw up issues.

    I had some success with the following code but I had to create interactive Pipeline Steps always referencing the last step, so the g.detail (a.detail...b.detail...etc etc).  So for a record save, where I am monitoring 7 fields, I have to have 7 iterative steps.


    {% set result = g.detail if g.detail is not none else "" %}
    
    {% if a.requested_offer_types != a.$prev.requested_offer_types %}
        {% set prev_req_types = a.$prev.requested_offer_types if a.$prev.requested_offer_types is not none else "unknown" %}
        {% set curr_req_types = a.requested_offer_types if a.requested_offer_types is not none else "unknown" %}
    
        {% set result = result + "\n" + "Requested Offer Type changed from '" + prev_req_types + "' to '" + curr_req_types + "'" %}
    {% endif %}
    
    {{ result }}

    The only item type it does not seem to work for are Checkbox's.  I can the the comparative test of old to new to work, but no matter what I do I can form any type of String for the Result.

  • OK I have updated as follows as I realised the opening string was incorrect and simply blank.

    However it still not working. 

    {# Capture the initial detail value that is passed into the template #}
    {% set initial_detail = g.detail %}
    
    {# Initialize a list starting with the initial content of j.detail #}
    {% set messages = [initial_detail] %}
    
    {# Check if the requested offer types have changed and append a message if true #}
    {% if a.requested_offer_types != a.$prev.requested_offer_types %}
        {# Create a message about the change #}
        {% set message = "Requested Offer Types changed from '" + a.$prev.requested_offer_types + "' to '" + a.requested_offer_types + "'" %}
        {# Append the message to the messages list #}
        {% set _ = messages.append(message) %}
    {% endif %}
    
    {# Output all accumulated messages, including initial and new ones, separated by new lines #}
    {{ messages | join('\n') }}

    I think the join is wrong.

     

     

     

    • PrashantMaheshw's avatar
      PrashantMaheshw
      Qrew Captain

      We recently solved something like this when a.$prev didn't work for us. In our case 

      1. Existing field was getting update via incoming webhook
      2. Step 1 , Receive webhook 
      3. Step 2 , Receive the value of existing value (which is what I am detailing here)
      4. Step 3 , Join existing value and webhook value 

        First do a query on
        https://api.quickbase.com/v1/records/query

      In my scenario it looked like below
      {  
      "from": "{{a.body_params.parentid}}",   --> tableid
      "select": ["{{a.body_params.fid}}"],    --> fid of record you want 
      "where": "{3.EX.{{a.body_params.recordid}}}" }. --> Query you

      This will allow you to 'get' the value of the existing field first. 

      This was stored inside for me
      {b.json.data[0]}

      Then another query doing make request and append value. Hope this makes sense

      As for your actual join , you can trying using ~ to concat like {{ (a.firstname) ~ ' ' ~ (a.lastname) }}