0
Answered

Email notifications based on old attribute values

Adrian Corston 4 years ago in UNIFYBroker/Plus updated by Beau Harrison (Senior Product Software Engineer) 4 years ago 3

Hi Matt,

In a past discussion with you I mentioned the importance of being able to know both the old and new value of an attribute when deciding to trigger an email notification, and this is an example of that.

Here’s an email requirement detail clarification just in from a UNIFYConnect customer:

“Speaking of emails, a manual process we may have missed. When a staff member is assigned an email address, we manually send them a welcome email from our CEO. If we provide the email content, etc, can you include this step in automation for new (email) users?”

Can you advise how I can detect that an email address attribute (imported from AD) has changed from blank to non-blank? Email addresses are assigned by Exchange policy so that’s the only way I can think of to detect and trigger the above action.

Answer

Answer

Matt wrote:

You could have a placeholder connector set up that contains ‘users with emails’, and only provision into that adapter/connector if they have an email address. Then run a post provisioning task that sends an email to them.
Or you could compare the entities to determine if a new value has been set in an email field, in one of your existing flows.

For the latter he is referring to the use of $sourceEntities and $targetEntities from PowerShell tasks.

Answer

Matt wrote:

You could have a placeholder connector set up that contains ‘users with emails’, and only provision into that adapter/connector if they have an email address. Then run a post provisioning task that sends an email to them.
Or you could compare the entities to determine if a new value has been set in an email field, in one of your existing flows.

For the latter he is referring to the use of $sourceEntities and $targetEntities from PowerShell tasks.

I've written a helper function to make this easy to do in  link synchronisation tasks, called Copy-EntityFieldValue in the UNIFY.Utils.BrokerPlus module.

Copy-EntityFieldValue -From staffName -To "Display Name" -OnChange {
  param($From, $To)
  $logger.LogInformation("Display Name changed from '$From' to '$To'")
}

Copy-EntityFieldValue mail "Email Address" -OnSet {
  param($To, $TargetEntity)
  Send-UNIFYConnectNotification -Subject "Welcome to Contoso" -Template "New Starter Welcome Email" -Substitution @{
    EmployeeName = $TargetEntity["Display Name"].Value
    ManagerName = $TargetEntity["Manager Name".Value
  }
}