Views:

Applies To:

GroupID 9 and 10 - Synchronize

Business Scenario:

We have an HR database where people have different roles in different departments and they are assigned different responsibilities within these departments from time to time. Does GroupID offer a functionality to generate a notification email for HR every time the department changes?

Solution:

This is achievable using a VB script in the Synchronize module. When the department of any user changes, it is updated in the HR database. This database is used as a source provider in a Synchronize job. When the job runs and finds updated values for ‘department’, it triggers an email notification to HR.

Steps:

  1. In GroupID Management Console, expand the Synchronize node, right-click All Jobs, and then select New Job.
  2. On the Job Template page, select a blank job and hit Next.
  3. Enter details for the source provider. In my case, I selected Microsoft SQL Server.
  4. Enter details for the destination provider. In my case, I selected Microsoft Active Directory (LDAP).
  5. On the Sync Object Options page, select the required object type and then select the Skip option for it.
  6. On the Select Fields page, select the field you want to update. I selected EmployeeID.
  7. On the Field Map(s) page, select your key attribute and click Edit Global Script.


     
  8. On the Global Script Editor window, click Tools > Add/Remove Reference on the menu.
  9. On the Add Reference dialog box, click Browse to browse to the following location, where you have to select the files: Imanami.Synchronize.ActiveDirectoryTool.dll and Imanami.Synchronize.NotificationTool.dll.
     
    [GroupID installation drive]:\Program Files\Imanami\GroupID X.0\Synchronize\PowerTools

  10. Now create two variables before DTM_Startup.  It will be as shown below:

    Dim EmailBody As stringBuilder
    Dim OrgDest As Imanami.Dtm.Scripting.IJobRunInternals


     
  11. Do one of the following, depending on SMTP server configuration:
    • If an SMTP server is configured for the identity store, then copy the following script and paste it under the DTM_Startup event to initialize the notification tool: 

      OrgDest = CType(DTM, Imanami.Dtm.Scripting.IJobRunInternals)
      ' NotificationTool.Initialize(OrgDest,"SMTP Server",25,"Authentic Emaill Address")
      ' If SMTP setting is configure in main configuration than
      NotificationTool.Initialize(OrgDest)

    • If an SMTP server is not configured, copy the following script and paste it under the DTM_Startup event to initialize the notification tool: 

      OrgDest = CType(DTM, Imanami.Dtm.Scripting.IJobRunInternals)
      NotificationTool.Initialize(OrgDest,"SMTP Server",25,"Authentic Emaill Address")
      ' If SMTP setting is configure in main configuration than
      ' NotificationTool.Initialize(OrgDest)


       
  12. Now navigate to the DTM_RowChanged event section and add the following lines. Once done, it will look somewhat like this: 

    Dim srcString as string
    Dim DestString as string
    Dim MsgBody As string
    Dim DispName As string
    SrcString = OrgDest.OriginalDestination("Department")
    DestString = args.StagingDestination("Department")
    DispName = OrgDest.OriginalDestination("Display Name")
    If SrcString <> DestString then
      MsgBody = "Employee " +  rtrim(OrgDest.OriginalDestination("givenName")) + " " +  rtrim(OrgDest.OriginalDestination("sn"))+ "'s"
      MsgBody = MsgBody + " Department has changed from [" + rtrim(SrcString) + "] To [" + rtrim(DestString) + "]. Message boday content"
    End If

    NotificationTool.SendNotification("From","To","Subject", MsgBody,False)




    If the value of ‘department’ in the source string is not equal to the value of ‘department’ in the destination string, then the job designs an email body and generates an email notification.
     
  13. Now click Build and then Compile Script.
  14. Save the script and click Next.
  15. Complete the Synchronize job and run it.

References:

GroupID Online Help - Synchronize