My requirement is to send notification alert to employee and its supervisor that the employee contract expire within a few days
I have created a class and get employee and its supervisor but looking for the notification syntax who fit in my scenario
here is my code and i want to notify the employee and its supervisor
Guide me
thanks in advance
internal final class notification_SYNPR { ////// Class entry point. The system will call this method when a designated menu /// is selected or when execution starts and this class is set as the startup class. /// /// The specified arguments. public static void main(Args _args) { HcmPositionWorkerAssignment HcmPositionWorkerAssignment,HcmPositionWorkerAssignmentloc; HRMParameters HRMParameters,HRMParametersloc; HcmPosition HcmPosition,HcmPositionloc; HcmPositionHierarchy hcmPositionHierarchy,hcmPositionHierarchyloc; HcmWorker hcmWorker,hcmWorkerloc; DirPerson dirPerson,dirPersonloc; DirPartyTable DirPartyTable,DirPartyTableloc; LogisticsElectronicAddress logisticsElectronicAddress,logisticsElectronicAddressloc; utcDateTime rangeStart, rangeEnd; date startDate, endDate; TimeOfDay startTime, endTime; SYNPR_SendNotification sendmail; EmailBase emailId; SysEmailTable sysEmailTable; Map mappings = new Map (Types::String, Types::String); List strlist = new List(Types::String); ListIterator iterator; EventInbox EventInbox; SysUserInfo SysUserInfo; str _strtoSplit,_delimiter,forTag,_mailsubject,_mailBody,_recieveraddress,employeemail,senderemail; System.Exception e; SysEmailSystemTable sysEmailSysTable; sysEmailSysTable = SysEmailSystemTable::find("D365"); sendmail = new SYNPR_SendNotification(); select firstonly HRMParameters; Timezone userTimeZone = DateTimeUtil::getUserPreferredTimeZone(); employeemail = 'mian55028@gmail.com'; senderemail = 'usama.mansaib02@gmail.com'; //for range on table to filter records startDate = today() HRMParameters.ContractEndDate; // day\month\year endDate = today() HRMParameters.ContractEndDate; // day\month\year startTime = str2time("00:00:00 am"); endTime = str2time("23:59:59 pm"); rangeStart = DateTimeUtil::newDateTime(startDate,startTime,DateTimeUtil::getUserPreferredTimeZone()); rangeEnd = DateTimeUtil::newDateTime(endDate,endTime,DateTimeUtil::getUserPreferredTimeZone()); while select * from HcmPositionWorkerAssignment where (HcmPositionWorkerAssignment.ValidTo >= rangeStart && HcmPositionWorkerAssignment.ValidTo <= rangeEnd) { select * from hcmWorker where hcmWorker.RecId == HcmPositionWorkerAssignment.Worker join dirPerson where dirPerson.RecId == hcmWorker.Person join dirPartyTable where dirPartyTable.RecId == dirPerson.RecId join logisticsElectronicAddress where dirPartyTable.PrimaryContactEmail == logisticsElectronicAddress.RecId; // supervisor select * from hcmPositionHierarchy where hcmPositionHierarchy.Position == HcmPositionWorkerAssignment.Position join HcmPositionloc where HcmPositionloc.RecId == hcmPositionHierarchy.ParentPosition join HcmPositionWorkerAssignmentloc where HcmPositionWorkerAssignmentloc.Position == HcmPositionloc.RecId join hcmWorkerloc where hcmWorkerloc.RecId == HcmPositionWorkerAssignment.Worker join dirPersonloc where dirPersonloc.RecId == hcmWorkerloc.Person join DirPartyTableloc where DirPartyTableloc.RecId == DirPartyTableloc.RecId join logisticsElectronicAddressloc where DirPartyTableloc.PrimaryContactEmail == logisticsElectronicAddressloc.RecId; // select SysUserInfo order by SysUserInfo.Id where SysUserInfo.Id!= curUserId(); //while select maxof(inboxId) from inbox where { // select maxof(inboxId) from inbox; EventInbox.initValue(); //EventInbox.AlertTableId = tablenum(Address); //EventInbox.AlertFieldId = fieldnum(Address, Name); //EventInbox.TypeTrigger = EventTypeTrigger::FieldChanged; EventInbox.SendEmail = false; EventInbox.TypeId = classnum(EventType); EventInbox.CompanyId = curext(); EventInbox.InboxId = EventInbox::nextEventId(); EventInbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime(); EventInbox.IsRead = NOYES::No; EventInbox.Subject = "Worker Contract"; EventInbox.AlertedFor = "Contract Expiry Alert"; EventInbox.UserId = curUserId(); EventInbox.ShowPopup = NOYES::Yes; EventInbox.Visible = NOYES::Yes; EventInbox.Message = strfmt("%1 your contract has been expire",HcmWorker::find( HcmPositionWorkerAssignment.Position).name()); EventInbox.insert(); } } } }