How to set bgcolor based on custom field value - Jira WorkFlow Toolbox post function - send an email [IMPORTANT]

Issue #854 resolved
Antonius Aditya created an issue

Hi, I am currently validating your add-ons, and I have a case. I want to make an email containing custom field single select value, there are "OK", "NOT OK", and "N/A"

in Jira WorkFlow Toolbox post function - send an email, i created a Table, and i want to set the bgcolor based on custom field value, like this : if value="OK" set bgcolor to green if else value="NOT OK" set bgcolor to red else set bgcolor to orange

Can you please help to solve my case?

Thank You

Comments (5)

  1. Fidel Castro Armario repo owner

    Hi @antoniiusadit,

    Currently Send an email post-function doesn't provide advanced parsing mode for the body of the email, so you can't create conditions like the one you need here, but you can use the following workaround:

    Before Send an email post-function, you can use Copy a parsed text to a field post-function in advanced parsing mode for storing in Ephemeral string 1 (field code %{00061}) the color, and then you can use field code %{00061} for setting bgcolor in the email body.

    In Copy a parsed text to a field you should use the following configuration:

    Captura de pantalla 2017-10-19 a las 10.38.18.png

    • Target field: Ephemeral string 1
    • Parsing mode: advanced
    • Text to be parsed...:
    getMatchingValue(%{nnnnn}, ["OK", "NOT OK", "N/A"], ["#008000", "#B22222", "#FF8C00"])
    

    replacing nnnnn with field code for your single Select List field.

  2. Fidel Castro Armario repo owner

    Now, I notice that you are using a quite old version of the plugin. In your case you should use the following text expression:

    %{nnnnn} = "OK" ? "#008000" : (%{nnnnn} = "NOT OK" ? "#B22222" : "#FF8C00")
    

    replacing nnnnn with field code for your single Select List field.

  3. Antonius Aditya reporter

    Hi @fcarmario Thanks for your answer. it's really works for me. I'am using v7.4.1 Jira Software

  4. Log in to comment