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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Initialize contract parameters for recurrence batch job in SysOperationFramework

(0) ShareShare
ReportReport
Posted on by 221

Hello,

We are using D365FO.

I have a contract class where i am initializing the "from date" and "to Date" by implementing sysOperationInitializable. I decorated my contract class with SysOperationAlwaysInitializeAttribute. when i manually run the batch job, contract taking newly initialized values every time but when i add this to a Batch Job with recurrence it is not taking the initialized values instead running with the same contract values every time.

could you please help me what is the issue?

Thanks,

Sandeep

*This post is locked for comments

I have the same question (0)
  • MSandy Profile Picture
    221 on at

    My code is like this:

    [DataContractAttribute, SysOperationAlwaysInitializeAttribute]

    public class DataContract implements SysOperationInitializable

    public void initialize()

       {

           fromDate    = prevQtr(DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()));

           toDate      = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());

       }

  • Suggested answer
    Martin Dráb Profile Picture
    239,647 Most Valuable Professional on at

    There is no issue; it works as expected. Values are initialized when the dialog is displayed, which happens when you're scheduling the batch, but not when the batch is executed.

    It seems that your intention is always setting the dates in code and not getting them from the dialog at all.

  • MSandy Profile Picture
    221 on at

    Thanks Martin for responding!

    Is it possible to make the date parameters from dialog be relative in which the recurrence will work?

    If that is not possible, how can we initialize the date range for every recurrence of batch job?

    Thanks

  • Verified answer
    Martin Dráb Profile Picture
    239,647 Most Valuable Professional on at

    Can you please elaborate what you mean by "relative in which the recurrence will work"?

    If you want to do something relative to the current day, you can simply call DateTimeUtil::utcNow() inside the operation.

  • MSandy Profile Picture
    221 on at

    what I understood from your previous reply is that batch job won't initialize the parameters every time while executing based on parameters initialized in Dialog while scheduling so we need to initialize that in code level for every recurrence.

    I'll try to add my piece of code

    fromDate    = prevQtr(DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()));

    toDate      = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());

    in service class of my batch job. I hope this works for every recurrence.

    Please add if anything required Martin, Thanks

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dserp Profile Picture

dserp 4

#2
dekion Profile Picture

dekion 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans