Get List of Users in an Email Template

Hi All,

Is there a way to get the list of users from the loop and put all those users in a single email template? It should look something like this:

Hi @jasmedina,

you can do that without using loop. You can pull your identities by using http request.

And then in the “Send Email” action you can use foreach on array attribute that you define in email template variable context.

I do an example here : Using IdentityNow Workflows to Send a List of Uncorrelated Accounts After Aggregation - Content / Community Blog - SailPoint Developer Community

...
<tbody>
				#foreach($account in $accounts)
				<tr>
					<td style="border: 2px solid grey; padding: 8px; text-align: center">
						${account.nativeIdentity}
					</td>
					<td style="border: 2px solid grey; padding: 8px; text-align: center">
						${account.name}
					</td>
				</tr>
				#end
</tbody>
...

in the templating context i define my “accounts” variablelike this :

{
	"accounts.$": "$.hTTPRequest.body",
	"aggregationCompletedDate.$": "$.trigger.completed",
	"ownerName.$": "$.getIdentity.attributes.displayName",
	"sourceName.$": "$.trigger.source.name",
	"totalAccounts.$": "$.hTTPRequest.headers['X-Total-Count'][0]",
	"uncorrelatedAccountsLink": "https://{{tenant}}.identitynow.com/ui/admin#admin:connections:sources:{{$.trigger.source.id}}:uncorrelatedAccounts"
}

My usecase is based for retrieving list of accounts particular source after aggregation you must adapt for your use which to retrieve list of identities.

My email look like :

You can found all informations in the blog.

1 Like

Which email template are you looking to leverage with this? Or are you firing this from a workflow? You could use something like this for example:

<table style="border:1px solid black;border-collapse:collapse">
    <tr>
        <td style="border:1px solid black;border-collapse:collapse"><b>Frist Name</b></td>
        <td style="border:1px solid black;border-collapse:collapse"><b>Last Name</b></td>
        <td style="border:1px solid black;border-collapse:collapse"><b>Email</b></td>
    </tr>
    #foreach( $identity in ${identities} )
    <tr>
        <td style="border:1px solid black;border-collapse:collapse">$identity.firstName</td>
        <td style="border:1px solid black;border-collapse:collapse">$identity.lastName</td>
        <td style="border:1px solid black;border-collapse:collapse">$identity.email</td>
    </tr>
    #end
</table>
1 Like

Thank you so much for your input! I will look into these.

Hi Alex,

What would be the templating context for the identities? Thank you!

This is an example - but you would want to pass in a JSON array of objects. This could be identities or accounts, depending on the data you’re working with. And depending on that you can tweak further.

Hi @jasmedina just an example how you can get identity and its respective information.

Example Email template body :
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: “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.

{“email.$”:“$.getIdentity.attributes.email”,“firstname.$”:“$.getIdentity.attributes.firstname”,“lastname.$”:“$.getIdentity.attributes.lastname”,“uid.$”:“$.getIdentity.attributes.uid”}

Refer: Actions - SailPoint Identity Services for more information.

Hope this helps.

Hi @jasmedina ,

As describe in my previous response, template context is used for define your email template :

{
	"accounts.$": "$.hTTPRequest.body",
	"aggregationCompletedDate.$": "$.trigger.completed",
	"ownerName.$": "$.getIdentity.attributes.displayName",
	"sourceName.$": "$.trigger.source.name",
	"totalAccounts.$": "$.hTTPRequest.headers['X-Total-Count'][0]",
	"uncorrelatedAccountsLink": "https://{{tenant}}.identitynow.com/ui/admin#admin:connections:sources:{{$.trigger.source.id}}:uncorrelatedAccounts"
}

Hi @jasmedina

Yes, it is indeed possible to send the list of employees in one email. You can use the velocity template syntax to iterate over each object for creating new rows.

The other experts have already shared many good examples, but if you need more, please let us know.

Thank You.
Regards
Vikas.

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