Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Generating Custom Notifications on a particular Date

Posted on by 165

Dear Gents;

I have crated a job that is displaying notifications for all the employees whose Passports are expiring in thee months.

Now i want to run this job incrementally so that by the end of each week HR Manager can see notification of passport expiry for each employee.

 Can somebody help how can achieve this Here is my job code.

static void Job22(Args _args)
{
HcmPersonIdentificationNumber hcmpersonidentificationnumber;
HcmWorker hcmworker;
HcmIdentificationType hcmidentificationtype;
userinfo infoo;
userinfo userinfo;
DirPerson myDirParty;
EventInbox inbox;

while select * from hcmworker join hcmpersonidentificationnumber where
hcmpersonidentificationnumber.RecId == hcmworker.RecId

{

if((hcmpersonidentificationnumber.expirationdate-today())<90 && hcmpersonidentificationnumber.IdentificationType == any2int64(5637145327))

{

print hcmworker.personnelnumber," ",hcmpersonidentificationnumber.expirationdate ," ",
hcmidentificationtype.identificationtypeid," your passport is Expiring Soom";


inbox.initvalue();

inbox.showpopup = noyes::yes;

inbox.subject = strFmt("regarding passport expiration for %1",hcmworker.personnelnumber);
select Name,RecId from myDirParty where myDirParty.RecId == hcmworker.Person;

inbox.message = strFmt("Passport for %1 is going to expire in 90 days please do renew",myDirParty.Name);

inbox.alertedfor = strFmt("Passport Expiry Date is %1",hcmpersonidentificationnumber.expirationdate );

inbox.sendemail = true;

inbox.userid = userinfo.id;

inbox.typeid = classnum(eventtype);

inbox.companyid = curext();

inbox.inboxid = eventinbox::nexteventid();

inbox.insert();

}

}
}

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Generating Custom Notifications on a particular Date

    You can use SysOperation framework or RunBaseBatch framework to run your code as a scheduled batch.

    Here's information about SysOperation framework: docs.microsoft.com/.../introducing-the-sysoperation-framework-white-paper

    For RunBaseBatch you can look at Tutorial_RunBaseBatch in AOT.

  • RE: Generating Custom Notifications on a particular Date

    HI Nikolaos;

    Thanks or your response, Yes my code is working fine. Just need help in running it automatically.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Generating Custom Notifications on a particular Date

    I'm not sure what you need help with. Is your code working as expected, and you only need help in running it automatically? Or do you have some issue with your code?

    You also started already one discussion about this topic, and you got some suggestions there: community.dynamics.com/.../notification-on-passport-expiry-date

    Did you already look into those suggestions? If you don't want to follow them, why?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans