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)

How to add job code in class

(0) ShareShare
ReportReport
Posted on by 2,430

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
    305,012 Super User 2026 Season 1 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,430 on at

    Hi  André,

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

  • Blue Wang Profile Picture
    Microsoft Employee 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
    305,012 Super User 2026 Season 1 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

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 28

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans