Novell Home

Automated E-mail on Employee Department Change

Novell Cool Solutions: Tip
By Armando A. Perez

Digg This - Slashdot This

Posted: 12 Jul 2006
 

Problem

We need to trigger an e-mail when employee changes department, with special rules to generate data sent in an e-mail.

Solution

The script below supports the typical notification when an employee changes department (Numbers). In addition, the script includes value-added code to retrieve and add to the email the employee's manager's first and last name, including the "effective move date" (mapped to Login Expiration Date).

The first rule detects if the move also includes a change in manager, and it performs a query on the Manager's DN (from the operation attribute) to extract the Given and Last Names. The e-mail is generated and sent, and the policy is exited (break).

The second rule assumes that there is no change in managers (the first rule would have trapped this condition). It performs a query on the user's object (in the IDVault) to extract the Manager's DN (from the destination "manager" attribute). This is used to extract the Given and Last Names of the current manager. The e-mail is then generated and sent.

Note: The following variables are used:
FromDisplayName = Reply To Address
ManagerGivenName = Given Name attribute of Employee's Manager
ManagerSurname = Surname attribute of Employee's Manager

Example

<?xml version="1.0" encoding="UTF-8"?><policy>
<rule>
<description>MODIFY/EMAIL : Detect Employee Transfer/Move (along with Supervisor ID change) 
and email appropriate people</description>
<conditions>
<and>
<if-operation op="equal">modify</if-operation>
<if-op-attr name="departmentNumber" op="changing"/>
<if-op-attr name="Manager" op="changing"/>
<if-attr name="employeeStatus" op="not-equal">T</if-attr>
</and>
</conditions>
<actions>
<do-set-local-variable name="ManagerGivenName">
<arg-string>
<token-dest-attr class-name="User" name="Given Name">
<arg-dn>
<token-op-attr class-name="User" name="manager"/>
</arg-dn>
</token-dest-attr>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="ManagerSurname">
<arg-string>
<token-dest-attr class-name="User" name="Surname">
<arg-dn>
<token-op-attr class-name="User" name="manager"/>
</arg-dn>
</token-dest-attr>
</arg-string>
</do-set-local-variable>
<do-send-email server="mail.company.edu" type="text">
<arg-string name="to">
<token-text xml:space="preserve">admin@company.edu</token-text>
</arg-string>
<arg-string name="to">
<token-text xml:space="preserve">admin2@company.edu</token-text>
</arg-string>
<arg-string name="subject">
<token-text xml:space="preserve">NOTICE : N120 : Employee Transfer - </token-text>
<token-src-attr class-name="User" name="Given Name"/>
<token-text xml:space="preserve"> </token-text>
<token-src-attr class-name="User" name="Surname"/>
<token-text xml:space="preserve"> - has been transfered to another department.</token-text>
</arg-string>
<arg-string name="message">
<token-text xml:space="preserve">Employee - </token-text>
<token-src-attr class-name="User" name="Given Name"/>
<token-text xml:space="preserve"> </token-text>
<token-src-attr class-name="User" name="Surname"/>
<token-text xml:space="preserve">, employee ID # </token-text>
<token-src-attr class-name="User" name="workforceID"/>
<token-text xml:space="preserve">, has moved to another department.  </token-text>
<token-text xml:space="preserve"/>
<token-text xml:space="preserve">The old department is </token-text>
<token-dest-attr class-name="User" name="OU"/>
<token-text xml:space="preserve">.  The new department is </token-text>
<token-attr name="OU"/>
<token-text xml:space="preserve"> (</token-text>
<token-attr name="departmentNumber"/>
<token-text xml:space="preserve">).  Supervisor's name is </token-text>
<token-local-variable name="ManagerGivenName"/>
<token-text xml:space="preserve"> </token-text>
<token-local-variable name="ManagerSurname"/>
<token-text xml:space="preserve">.  Effective Date is </token-text>
<token-substring length="10">
<token-attr name="Login Expiration Time"/>
</token-substring>
<token-text xml:space="preserve">.</token-text>
</arg-string>
<arg-string name="from">
<token-global-variable name="FromDisplayName"/>
</arg-string>
</do-send-email>
<do-break/>
</actions>
</rule>
<rule>
<description>MODIFY/EMAIL : Detect Employee Transfer/Move (with no Supervisor ID change) 
and email appropriate people</description>
<conditions>
<and>
<if-operation op="equal">modify</if-operation>
<if-op-attr name="departmentNumber" op="changing"/>
<if-attr name="employeeStatus" op="not-equal">T</if-attr>
</and>
</conditions>
<actions>
<do-set-local-variable name="ManagerGivenName">
<arg-string>
<token-dest-attr class-name="User" name="Given Name">
<arg-dn>
<token-dest-attr class-name="User" name="manager"/>
</arg-dn>
</token-dest-attr>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="ManagerSurname">
<arg-string>
<token-dest-attr class-name="User" name="Surname">
<arg-dn>
<token-dest-attr class-name="User" name="manager"/>
</arg-dn>
</token-dest-attr>
</arg-string>
</do-set-local-variable>
<do-send-email server="mail.company.edu" type="text">
<arg-string name="to">
<token-text xml:space="preserve">admin@company.edu</token-text>
</arg-string>
<arg-string name="to">
<token-text xml:space="preserve">admin2@company.edu</token-text>
</arg-string>
<arg-string name="subject">
<token-text xml:space="preserve">NOTICE : N120 : Employee Transfer - </token-text>
<token-src-attr class-name="User" name="Given Name"/>
<token-text xml:space="preserve"> </token-text>
<token-src-attr class-name="User" name="Surname"/>
<token-text xml:space="preserve"> - has been transfered to another department.</token-text>
</arg-string>
<arg-string name="message">
<token-text xml:space="preserve">Employee - </token-text>
<token-src-attr class-name="User" name="Given Name"/>
<token-text xml:space="preserve"> </token-text>
<token-src-attr class-name="User" name="Surname"/>
<token-text xml:space="preserve">, employee ID # </token-text>
<token-src-attr class-name="User" name="workforceID"/>
<token-text xml:space="preserve">, has moved to another department.  </token-text>
<token-text xml:space="preserve"/>
<token-text xml:space="preserve">The old department is </token-text>
<token-dest-attr class-name="User" name="OU"/>
<token-text xml:space="preserve">.  The new department is </token-text>
<token-attr name="OU"/>
<token-text xml:space="preserve"> (</token-text>
<token-attr name="departmentNumber"/>
<token-text xml:space="preserve">).  Supervisor's name is </token-text>
<token-local-variable name="ManagerGivenName"/>
<token-text xml:space="preserve"> </token-text>
<token-local-variable name="ManagerSurname"/>
<token-text xml:space="preserve">.  Effective Date is </token-text>
<token-substring length="10">
<token-attr name="Login Expiration Time"/>
</token-substring>
<token-text xml:space="preserve">.</token-text>
</arg-string>
<arg-string name="from">
<token-global-variable name="FromDisplayName"/>
</arg-string>
</do-send-email>
</actions>
</rule>
</policy>


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell