web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Minimum Time for an email to stay in the Queue for Dynamics AX 2009

(0) ShareShare
ReportReport
Posted on by 130

Hi,

I recently setup our Invoices & Statements to be emailed out directly from Dynamics.
I've just had a request come back to make the emails stay in the queue for an hour before they get sent out.

This is to give the users time to realize they made a mistake and locate the item in the queue and delete it before it goes out to the customer.

Does anyone know if this is possible? The email batch processing job doesn't have any sort of options around making sure the created time is at least 1 hour ago before running it (that I found anyway) I'm not even sure where I can go in X++ to control the behavior of the email batch processing job.

The easiest option is for the email batch to set the emails to go out at 6pm (1 hour after close of business), but that's not quite what was intended.

<insert lengthy pause as I just went and checked something and answered the question for myself>

Funny how simply the act of writing out your question can lead you to the solution. I was going to close this but then thought others might find it useful.

I found the class I needed to edit was called sysEmailDistributor.

Inside the run method there was a while select that ran over all of the emails to be sent.

I changed the where clause from ...(outgoingEmailTable.Status == SysEmailStatus::Unsent)...

to ...(outgoingEmailTable.Status == SysEmailStatus::Unsent) &&
                    (outgoingEmailTable.createdDateTime <= DateTimeUtil::addHours(DateTimeUtil::utcNow(),-1)) ...

Quick fix I know. I'll extend it by creating the -1 as a parameter and have it able to be set inside Dynamics rather than being just a magic number buried inside the code. But if anyone has a similar problem...  

Thanks,

Adam

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Adam Duckworth Profile Picture
    130 on at

    Answered in main post

  • Mea_ Profile Picture
    60,284 on at

    Another thing you can change is use DateTimeUtil::getSystemDateTime() instead of DateTimeUtil::utcNow(). You may noticed that standard code uses DateTimeUtil::getSystemDateTime() to work with retry time in the same statement, so if you will change your system date time through client it would be honored by retry but not your code.

  • Adam Duckworth Profile Picture
    130 on at

    I'm a little confused as to what you're getting at though. The email batch is inside a batch process on the server, so if I change the AOS's system date time for some reason then... wouldn't I risk screwing up a whole lot of records that are all date/time stamped???

    This page kashperuk.blogspot.co.nz/.../q-session-working-with-utcdatetime-from.html seems to suggest that people can play around with their session date times (which I don't understand why you would want/need to). I think I like the more fixed timestamp that utcnow gives. (Maybe I should "update" the retry time code to use UtcNow :) )

    In either case its a somewhat moot point as our company doesn't span multiple timezones so its unlikely ever to crop up as a problem.

  • Mea_ Profile Picture
    60,284 on at

    If you don't understand something it does not mean that you need to fix it.  

    Session date time change is a very powerful feature. You can use it if you need to do something in AX in a past or a future. technet.microsoft.com/.../aa586010.aspx

    SysEmailDistributor is derived from RunBaseBatch. It has a standard functionality to run in a batch mode, however it could be run from menu without a batch. In this case standard code will use current session date time and your line current date time.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans