Skip to main content

Updating templates that use custom fields

Comments

1 comment

  • Philip R

    In case it's not readily apparent, customer-level custom fields are accessed in the same manner but using

    {% for customField in customer.custom_field_assignments %}
    ...

    Also, note that if you try to use handles like:

    {% assign x = job.custom_field_assignments | first %}
    {{ x.field_value }}

    ...what will be returned is the custom field whose entry has the numerically highest internal ID, and has nothing to do with the order the custom fields are listed on the job.

    If you'd rather treat them as two arrays, one of the field names and one of the values, you can do this:

    {% assign values = job.custom_field_assignments | map: "field_value" %}
    {% assign field_names = job.custom_field_assignments | map: "custom_field_configuration" | map: "name" %}

    {{ field_names[0] }} : {{ values[0] }}<br>
    {{ field_names[1] }} : {{ values[1] }}<br>
    {{ field_names[2] }} : {{ values[2] }}<br>
    {{ field_names[3] }} : {{ values[3] }}<br>

     

    0

Please sign in to leave a comment.

Powered by Zendesk