Workflows: How to default to an empty string for empty identity attribute?

Hi all,

I want to send an email using the workflow. Not all identity attributes may be set, and I want them to be displayed as empty string in the e-mail if they are not set.

Body of e-mail: ${title} ${titlex}
Templating Context:

{
  "title.$":"$.getJoinerIdentity.attributes[?(@.title)].title",
  "titlex.$":"$.getJoinerIdentity.attributes.title"
}

The input.body.context for the Send Email step as visible in the “Text Execution”:

E-mail Result: ${title} {$titlex}
Expected e-mail result:

I am sure I’m missing something obvious on how to solve this issue.

Best regards,
Andrei

Hi @adamian,

In the email body of your “send email” workflow step, you can use velocity script’s if-else condition.

For example: if you want to check when string value is not null #if(${title}) ${title} ${titlex} #else (your else condition if any) #end

If you want to check when string is null #if(!${title}) ${title} ${titlex} #else (your else condition if any) #end

Hope this works for you.

Thank you.
Shanmukh Gali

3 Likes

I think @Shanmukh has the correct answer here. The workflow email step supports apache velocity similar to how email templates do.

Thanks @Shanmukh, I’ll try this this works (with both title and titlex).

This doesn’t work in the static transform (which also uses Apache Velocity), so I didn’t think this could work here.