Skip to main content
Question

Pipelines and appending / joining


Forum|alt.badge.img+4

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

 

This topic has been closed for replies.

Forum|alt.badge.img+4

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.

 

 

 


Forum|alt.badge.img+4

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.