This is the option to get the confirmation mail to the selected user for confirming employee probation prior to completion of his probation.
Run the stored procedure in the database.
Procedure:
Create
PROCEDURE pPay_SendProbationAlert
(
@xmlIn AS XML = NULL
,@xmlOut AS XML = NULL OUT
)
AS
BEGIN
SET NOCOUNT ON;
SET @xmlOut = @xmlIn
DECLARE @Key AS VARCHAR(50)='iTransId'
DECLARE @InEmployeeIds as NVARCHAR(max)=''
DECLARE @OutEmployeeIds as NVARCHAR(max)=''
--Retriving Employee Id
select top 1 @InEmployeeIds = v.value('Value[1]', 'varchar(max)')
FROM @xmlIn.nodes('/ArrayOfKeyValuePair/KeyValuePair') x(v)
SELECT @OutEmployeeIds = isnull(STUFF((
SELECT ',' + convert(VARCHAR(20), mPay_Employee.iMasterId)
FROM muPay_Employee
INNER JOIN mPay_Employee ON muPay_Employee.iMasterId = mPay_Employee.iMasterId
WHERE DATEDIFF(dd, getdate(), DATEADD(mm, fProbationPeriod, dbo.IntToDate(dDateofJoining))) + 1 = 7
AND iEmployeeStatus = 70
FOR XML PATH('')),1,1,''),0)
SET @xmlOut.modify('replace value of(ArrayOfKeyValuePair/KeyValuePair[Key = sql:variable("@Key")]/Value/text())[1] with sql:variable("@OutEmployeeIds")'
)
END
Create Work flow after executing the procedure.
Settings>>Approval>>Work Flow
Enter the stored procedure name against Formula field for work flow definition.
Under Actions tab, select Email and add Probation – Employee master under Template field.
Select recipient type as per the requirement from the below list. Also select the recipient. In the above screen, recipient type is reporting to and recipient is level 1. Means the reporting manager of the employee will get the mail for his confirmation.
In the above example, the flow is defined as, 7days prior to the completion of probation confirmation, a mail will be triggered to the reporting manager for his confirmation.
Ex: Lets say Employee joined on 17-10-2018, and the probation period is 3 months. So as per the procedure, the reporting manager will get a mail on 11-01-2019 for confirmation which is 7 days prior to the probation period completion.
Comments
Post a Comment