---
title: User create event with email workflow example
description: In this example, an administrator creates a workflow that:
component: pingoneaic
page_id: pingoneaic:identity-governance:administration/example-user-create-event-send-email-workflow
canonical_url: https://docs.pingidentity.com/pingoneaic/identity-governance/administration/example-user-create-event-send-email-workflow.html
keywords: ["workflows", "use cases", "examples", "events", "user create event", "email"]
section_ids:
  assumptions: Assumptions
  example: Example
---

# User create event with email workflow example

In this example, an administrator creates a workflow that:

* Sends an email notification to the new user when a user create event occurs.

* Copies their manager, as well, if present.

## Assumptions

* Each user has a manager.

* Make sure to catch any error/failure conditions.

## Example

![An example of user create event send email workflow.](../_images/governance-workflow-example-user-create-event-send-email.png)

* 1 The Script node sends email to the new user and cc's to the user's manager.

  > **Collapse: Click to display send email script**
  >
  > ```js
  > logger.info("Running user create event role workflow - send email");
  >
  > var content = execution.getVariables();
  > var requestId = content.get('id');
  >
  > // Read event user information from request object
  > try {
  >   var requestObj = openidm.action('iga/governance/requests/' + requestId, 'GET', {}, {});
  >   var userObj = requestObj.request.common.blob.after;
  >   var userDisplayName = userObj.givenName + " " + userObj.sn + " (" + userObj.userName + ")";
  >   var body = {
  >     subject: "New user created: " + userDisplayName,
  >     to: userObj.mail,
  >     body: "New user created: " + userDisplayName + ".",
  >     object: {}
  >   };
  >   if (userObj && userObj.manager && userObj.manager.mail) {
  >     body.cc = userObj.manager.mail
  >   };
  >   openidm.action("external/email", "send", body);
  > }
  > catch (e) {
  >   logger.info("Unable to send new user creation email");
  > }
  >
  > // Update event request as final
  > var decision = {'status': 'complete', 'outcome': 'fulfilled', 'decision': 'approved'};
  > var queryParams = { '_action': 'update'};
  > openidm.action('iga/governance/requests/' + requestId, 'POST', decision, queryParams);
  > logger.info("Request " + requestId + " completed.");
  > ```

|   |                                                                                                                                                                                                                                                           |
| - | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|   | Download the JSON file for this workflow [here](../_attachments/workflows/workflowUIUserCreateEventSendEmailWorkflowExample.json).Learn more about how to import or export workflows in [workflow editor canvas](workflow-configure.html#orch-ui-canvas). |
