# Dynamic Values in Send Email - Workflow

**URL:** <https://developer.sailpoint.com/discuss/t/dynamic-values-in-send-email-workflow/88164>\
**Category:** SHF Discussion and Questions\
**Tags:** workflows, identity-security-cloud\
**Created:** [November 1, 2024, 4:48pm UTC](https://developer.sailpoint.com/discuss/t/dynamic-values-in-send-email-workflow/88164 "2024-11-01T16:48:06Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Santhakumar](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/santhakumar/32/17329_2.png) [@Santhakumar](https://developer.sailpoint.com/discuss/u/Santhakumar)\
**Post date:** [November 1, 2024, 4:48pm UTC](https://developer.sailpoint.com/discuss/t/dynamic-values-in-send-email-workflow/88164/1 "2024-11-01T16:48:06Z")

</div>

Hi All,  
Did anyone know how to use dynamic values in Workflow. I have refered the below link but not get the detailed info.

> [@Workflow - Send Email - Dynamic Email Content](https://developer.sailpoint.com/discuss/t/workflow-send-email-dynamic-email-content/5512):
>
> Hi All, I’d like to use workflows to send an email when some identity attributes change. I was wondering if the Send Email action supports dynamically building the email based on (for example) an identity attribute. I.e. if staff type = X: include text in email body such as ‘You’re a X user type’ if staff type = Y: include text in email body such as ‘You’re a Y user type’ etc Is this possible in the workflow send email step? I’ve tried adding in velocity type statements to the body and to…

Pls share if you try this.

Thanks.

---

<div class="post-metadata">

**Author:** ![shaileeM](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/shaileem/32/15314_2.png) [@shaileeM](https://developer.sailpoint.com/discuss/u/shaileeM)\
**Post date:** [November 1, 2024, 6:52pm UTC](https://developer.sailpoint.com/discuss/t/dynamic-values-in-send-email-workflow/88164/2 "2024-11-01T18:52:46Z")

</div>

Hi @Santhakumar ,

Can you elaborate more on the use case ?

The email body is `Send Email` in a workflow uses HTML, so you can use HTML if and else to populate the dynamic values in the email body.

HTH

---

<div class="post-metadata">

**Author:** ![Santhakumar](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/santhakumar/32/17329_2.png) [@Santhakumar](https://developer.sailpoint.com/discuss/u/Santhakumar)\
**Post date:** [November 2, 2024, 12:18pm UTC](https://developer.sailpoint.com/discuss/t/dynamic-values-in-send-email-workflow/88164/3 "2024-11-02T12:18:45Z")

</div>

@shaileeM I need to send the email based on the department so i have tried inserting if else in email body but it throws me an 400 bad request.

 ![image](https://global.discourse-cdn.com/sailpoint/original/3X/3/f/3f0a09ec4ef2060620e72601a02745ae859d1191.png)

Any idea how to get this or am i making any mistake?

Thanks.

---

<div class="post-metadata">

**Author:** ![ipobeidi](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/ipobeidi/32/16000_2.png) [@ipobeidi](https://developer.sailpoint.com/discuss/u/ipobeidi)\
**Post date:** [November 2, 2024, 1:37pm UTC](https://developer.sailpoint.com/discuss/t/dynamic-values-in-send-email-workflow/88164/4 "2024-11-02T13:37:31Z")

</div>

You can use velocity to have if and else statements on the email step like this :  
For example  
#if($!oldLastName)\n **Old LastName:** ${oldLastName}   
#end

This would only print if the variable has a value. you can do complex things 🙂

---

<div class="post-metadata">

**Author:** ![neeraj99](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/neeraj99/32/14001_2.png) [@neeraj99](https://developer.sailpoint.com/discuss/u/neeraj99)\
**Post date:** [November 3, 2024, 3:21pm UTC](https://developer.sailpoint.com/discuss/t/dynamic-values-in-send-email-workflow/88164/5 "2024-11-03T15:21:01Z")

</div>

Hey @Santhakumar Did you set the context as well?

**Example Email template body :**

```auto
Greetings ${firstname}, ${lastname},

We are pleased to inform you that your MFA Account on XYZ application has been successfully created.
Email : ${email}
Username : ${uid}

```

**CONTEXT:**

Context here basically means that whatever variables that you are using in the body, how will they be evaluated?  
So we define that in context saying if $email is the variable what information/data will it store. So we are giving the JSON path of the value that it should put in $email

Ex:

```auto
"email.$":"$.getIdentity.attributes.email"

```

Here, it basically means that, email will be the name of the variable that you are going to use in the template. and for the respective value, we are saying tha t goto action-\> getIdentity-\> attributes-\>email and store that in this variable.

```auto
{"email.$":"$.getIdentity.attributes.email","firstname.$":"$.getIdentity.attributes.firstname","lastname.$":"$.getIdentity.attributes.lastname","uid.$":"$.getIdentity.attributes.uid"}

```

Refer: [Actions - SailPoint Identity Services](https://documentation.sailpoint.com/saas/help/workflows/workflow-actions.html#send-email) for more information.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Santhakumar](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/santhakumar/32/17329_2.png) [@Santhakumar](https://developer.sailpoint.com/discuss/u/Santhakumar)\
**Post date:** [November 4, 2024, 12:38pm UTC](https://developer.sailpoint.com/discuss/t/dynamic-values-in-send-email-workflow/88164/6 "2024-11-04T12:38:47Z")

</div>

@neeraj99 Thanks for the input will check this and let you know if works.

---

<div class="post-metadata">

**Author:** ![neeraj99](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/neeraj99/32/14001_2.png) [@neeraj99](https://developer.sailpoint.com/discuss/u/neeraj99)\
**Post date:** [November 4, 2024, 2:22pm UTC](https://developer.sailpoint.com/discuss/t/dynamic-values-in-send-email-workflow/88164/7 "2024-11-04T14:22:38Z")

</div>

Sure, FYI for every variable that you are trying to use in the send-email action you need to define it in the context.

---

<div class="post-metadata">

**Author:** ![shaileeM](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/shaileem/32/15314_2.png) [@shaileeM](https://developer.sailpoint.com/discuss/u/shaileeM)\
**Post date:** [November 6, 2024, 5:54pm UTC](https://developer.sailpoint.com/discuss/t/dynamic-values-in-send-email-workflow/88164/8 "2024-11-06T17:54:16Z")

</div>

Hi @Santhakumar ,

Yes agree with @neeraj99 . You will need to declare the variables in the templating context so that you can use them in the email body.

Thanks,  
Shailee

---

<div class="post-metadata">

**Author:** ![Santhakumar](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/santhakumar/32/17329_2.png) [@Santhakumar](https://developer.sailpoint.com/discuss/u/Santhakumar)\
**Post date:** [November 6, 2024, 6:18pm UTC](https://developer.sailpoint.com/discuss/t/dynamic-values-in-send-email-workflow/88164/9 "2024-11-06T18:18:29Z")

</div>

@shaileeM and @neeraj99 Agreed already added the context and try the if else condition in email body its working fine. Thanks for the input.

Thanks,  
Shantha Kumar

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [January 5, 2025, 6:18pm UTC](https://developer.sailpoint.com/discuss/t/dynamic-values-in-send-email-workflow/88164/10 "2025-01-05T18:18:57Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
