Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Send Email when table's date field is the same as the current system date Today() AX2012R3

Posted on by 529

Hi all,

I have a custom date field in the ProdTable "DateReminder". So when today() = ProdTable.DateReminder I need to send and automatic email to the production responsible as a reminder to start the related production.

I have two main questions here.

1. what kind of event can be used to trigger the custom process/method daily to send the email when the condition applies.

2. What would be the best solution to send this email only once. ( I am trying to avoid an additional NoYes field to the production to not increase the modifications to AX standard objects)

I know i am probably asking a silly question here, But I prefer ask for experience here since I haven't tried this kind of events.

thanks a lot for your time beforehand.

really appreciated.

  • Suggested answer
    CBNestor Profile Picture
    CBNestor 529 on at
    RE: Send Email when table's date field is the same as the current system date Today() AX2012R3

    I Manage to fix it.

    There was an error on the server. since the batch job code is run on CIL I went to the server's Event log and I found out  the error was related to the sysRecurrenceData Container

    pastedimage1626433907958v1.png

    By debugging the code with VS; what Happened was because -By playing around with the code- I changed the SysRecurrence Version (first position in the container) to another container instead of an Integer value sysRecurrenceData = conPoke(SysRecurrenceData,1,[10]);. and that made the error exception on the server which led all running Batch jobs in a "Execution" idle state.

    by an X++ Job I could Update the record for that specific BatchJob to batchjob.RecurrenceData = SysRecurrence::defaultRecurrence();

    now all jobs are running as normal .

    quite a headache.

    At the end I solved my thread by using my logic executed by a scheduled batch job and alerts as per the first recommendation (  AT982020 ) . with SysOperationServiceController

    the option form Rachit Garg, was very interesting as well . I did not know that feature but I will probably use it in the future.

    Thanks a lot for your time guys!

  • CBNestor Profile Picture
    CBNestor 529 on at
    RE: Send Email when table's date field is the same as the current system date Today() AX2012R3

    I have been playing around with the BatchJob

    I have created a runBaseBatch class for my logic. But I am not able to select my class in the task is not showing up in the lookup field. So instead of making the batch job by UI I made from a x++ job. everything was working so far UNTIL..

     I found out this code . I accdidentally made some changes in the parameter and now every Batch I make get idle in state of  "Executing" I cannot delete them, change them. Even If I change the status to cancelling is still the same. Even if I create new ones from code with original code every new get broken.

    And can not make by hand from UI because my class cannot be selected.

  • CBNestor Profile Picture
    CBNestor 529 on at
    RE: Send Email when table's date field is the same as the current system date Today() AX2012R3

    Well,

    It must run some logic I think, it probably has to call a custom method from the ProdTable or a job at least.

    the Email has to be sent to the prodTable.createdBy and to the Related salesTable.SalesResponsible.

    Thanks for your answers I will make some more research of the batch jobs. I have to see the difference between a Task and an alert which will suit better.

  • ergun sahin Profile Picture
    ergun sahin 8,812 Moderator on at
    RE: Send Email when table's date field is the same as the current system date Today() AX2012R3

    If you're going to send an info mail only, due date alerts make the most sense (no development required).

    I thought you'd send a custom mail (with extras)

  • Verified answer
    Rachit Profile Picture
    Rachit 4,011 User Group Leader on at
    RE: Send Email when table's date field is the same as the current system date Today() AX2012R3

    You should explore Due date alert and can send an email as part of alert setup itself.

    docs.microsoft.com/.../due-date-type-events

    You should be able to setup due date alert on the custom field from UI directly and this should not require any development unless there are some rules which you want to setup which cannot be configured in alerts.

  • ergun sahin Profile Picture
    ergun sahin 8,812 Moderator on at
    RE: Send Email when table's date field is the same as the current system date Today() AX2012R3

    You can set up a batch job. (Run an extra time for yesterday's recordings after the clock has passed 12, in case there is a new record created after the batch runs (if there is such a possibility))

    You can make a mapping table and keep a RefrecId. If there is no record in this table, send it and enter a record in this table.

  • Verified answer
    AT982020 Profile Picture
    AT982020 509 on at
    RE: Send Email when table's date field is the same as the current system date Today() AX2012R3

    I don't think there are events that check table data periodically.

    A possible solution to your requirement is to create an operation/batch job that runs periodically (in your case each day) and checks ProdTable records with today() = ProdTable.DateReminder.

    Another possible solution is to create a batch job for each ProdTable record after record is inserted/updated and have starting date for the operation at DateReminder.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,277 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,135 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans