4 Replies Latest reply on Aug 23, 2018 6:28 AM by dcogny

    Send email quick action with conditional content

    BeckD Rookie

      Hi,

       

      I am trying to create a Send Email quick action to be used as part of my workflow for my request offering.

       

      The idea is that the workflow will generate an email to a particular recipient (who is not a Service Manager user) requesting them to do something when it has been requested.

       

      The problem i am facing is that the content of the email body is conditional upon what the requester has selected on the form.  I have 2 fields, lets call them Option A and Option B.  In my email if the requester has selected either of Option A or B, I want the option selected included, however if that have not selected a value for the field, I don't want anything displayed at all.

       

      In otherwords, if the requester selected Option A but not option B, I want my email to include in the body:

       

      Please perform the following actions:

      Option A - <the value selected for the Option A field>

       

      If the requester selected something from both Option A and Option B fields, I want the email to include in the body:

      Please perform the following actions:

      Option A - <the value selected for the Option A field>

      Option B - <the value selected for the Option B field

       

      Note that this is also formatted in an HTML table just to complicate things.

       

      What I am finding is that when I enter the code with the conditional If functions into the Quick Action, the If statement is moved to the top and all the HTML moved below every time I save.

       

      so if I have code that looks like:

       

      <table><tbody><tr><td colspan="2">Please perform the following actions:</td></tr>

      $(if OptionA != "" then "<tr><td>Option A:</td><td> " + Option A  + "</td></tr>" else "")

      $(if OptionB != "" then "<tr><td>Option B: </td><td>" + Option B  + "</td></tr>" else "")

      </tbody></table>

       

      When I save the QuickAction, it gets converted to something like this:

       

      $(if OptionA != "" then "" else "")

      $(if OptionB != "" then "" else "")

      <table><tbody><tr><td colspan="2">Please perform the following actions:</td></tr>

      <tr><td>Option A: </td><td>" + Option A + "</td></tr>

      <tr><td>Option B: </td><td>" + Option B + "</td></tr>

      </tbody></table>

       

       

      I have also tried changing this around so that the whole thing is encapsulated in the $() and the HTML is quoted as text, but I still get a similar result. Can anyone see what I am doing wrong?

        • 1. Re: Send email quick action with conditional content
          dcogny Expert

          Hi,

           

          I have used conditional on emails before, so it has to work, I can see right on your code that you have some typos, so, please try:

           

          <table><tbody><tr><td colspan="2">Please perform the following actions:</td></tr>

          $(if nvl(OptionA, "") != "" then "<tr><td>Option A:</td><td> " + OptionA + "</td></tr>" else null)

          $(If nvl(OptionB, "") != "" then "<tr><td>Option B: </td><td>" + OptionB  + "</td></tr>" else null)

          </tbody></table>

           

          Let me know if this works for you.

           

          Daniel.

          1 of 1 people found this helpful
          • 2. Re: Send email quick action with conditional content
            BeckD Rookie

            Sorry for the late response. Was out sick for the rest of last week.

             

            I have tried your suggestion, but still get the same result. I now end up with :

             

            $(if nvl(OptionA,"") != "" then "" else null)

            $(if nvl(OptionB,"") != "" then "" else null)

            <table><tbody><tr><td colspan="2">Please perform the following actions:</td></tr>

            <tr><td>Option A:</td><td>" + Option A + "</td></tr>

            <tr><td>Option B: </td><td>" + Option B + "</td></tr>

            </tbody></table>

             

            so in my table, I literally see the text

             

            " + Option A + "

            " + Option B + "

             

            without the system looking up the values of Option A and B. I have edited my original post to remove typos.

            • 3. Re: Send email quick action with conditional content
              BeckD Rookie

              I have contacted Ivanti support and it turns out this is a product bug. Hopefully it will be fixed soon.

              1 of 1 people found this helpful
              • 4. Re: Send email quick action with conditional content
                dcogny Expert

                OH! That would explain it...

                 

                Thanks for updating the post! Good luck.