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)

How to add job code in class

(0) ShareShare
ReportReport
Posted on by 2,382

Hi Experts,

Our requirement to auto cancel Sales Order if Sales Order created 3 day longer. I tested with Job as given below but I would like to know how to add in class.

static void AutoCancelSO(Args _args)
{
SalesTable salesTable;
   
    update_recordSet salesTable setting SalesStatus=SalesStatus::Canceled where salesTable.createdDateTime >= DateTimeUtil::addDays(DateTimeUtil::utcNow(), -3);
    
   
    
}


*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    300,928 Super User 2025 Season 2 on at

    Hi Faiz7049,

    You can create a class and move the coding in it. Do you need to be able to run the class as batch job? How to do it exactly depends on this question. You can have a look at many other classes in the system to learn how.

  • faiz7049 Profile Picture
    2,382 on at

    Hi  André,

    I want to execute code automatically everyday. How to do it.

  • Blue Wang Profile Picture
    on at

    Hi Faiz,

    Batch jobs can be added and automatically executed.

    There's a little guide: https://www.linkedin.com/pulse/microsoft-dynamics-ax-r3-batch-job-creation-through-code-gulfam

     I hope it will help you.

  • André Arnaud de Calavon Profile Picture
    300,928 Super User 2025 Season 2 on at

    Hi Faiz,

    The guide provided by Blue Wang is a good start. A similar document can be found here: docs.microsoft.com/.../walkthrough-extending-runbasebatch-class-to-create-and-run-a-batch

    If you need a dialog to make the number of days configurable, you can also read the next page: docs.microsoft.com/.../using-classes-to-create-a-dialog

    In that case, you need to implement pack and unpack to store the dialog values: docs.microsoft.com/.../pack-unpack-design-pattern

  • István Orosz Profile Picture
    2,137 on at

    Hi Faiz,

    Documentation was linked before me, just a practical advice:

    - if all you want to implement is this short logic, a simple RunBaseBatch would be enough, do not need to bother with the SysOperation framework.

    Kind regards,

    István Orosz

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
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans