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)

What is the right way to batch update sales order types ?

(0) ShareShare
ReportReport
Posted on by 100

what is the right way to batch update salesOrder type ?
I created a class that extended RunBaseBatch.
In this class have a method like this:

while
...
{
...
update_recordset salesTable
setting
SalesType =SalesType::Sales
where salesTable.SalesId ==_salesId;
...
}

the method batch update SalesType from Journal to Sales.this class and method run correct when i test in Jobs  but in batch job this throw errors:
-----------
Microsoft.Dynamics.Ax.Xpp.ErrorException: “Microsoft.Dynamics.Ax.Xpp.ErrorException”。

at Microsoft.Dynamics.Ax.MSIL.Interop.throwException(Int32 ExceptionValue)
at Microsoft.Dynamics.Ax.MSIL.cqlCursorIL.UpdateAll(IntPtr table)
at Dynamics.Ax.Application.OP_SalesOrderConfirmtionCreater.Altersosalestype(String _salesId, SalesType _salesType) Position at OP_SalesOrderConfirmtionCreater.AlterSoSalesType.xpp:Line 11
at Dynamics.Ax.Application.OP_SalesOrderConfirmtionCreater.Run() Position OP_SalesOrderConfirmtionCreater.run.xpp:line 17
at Dynamics.Ax.Application.BatchRun.runJobStaticCode(Int64 batchId) position BatchRun.runJobStaticCode.xpp:line 54
at Dynamics.Ax.Application.BatchRun.runJobStatic(Int64 batchId) position BatchRun.runJobStatic.xpp:line 13
at BatchRun::runJobStatic(Object[] )
at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)
at BatchIL.taskThreadEntry(Object threadArg)
------------
Or is there any other way to do that? ( call ax2012 Standard Methods ...)

thinks!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,898 Most Valuable Professional on at

    Changing the sales type can have enormous impact and I'm not sure whether it's handled automatically by update() method. I would be rather surprised if it was supported, especially for all possible combinations.

    Anyway, if you want to go ahead, I would recommend to test and debug it on a individual orders and in X++, instead of immediately jumping into set-based updates and CIL.

  • Community Member Profile Picture
    on at

    Can you please post complete Job which is giving error

    it seems you are trying to update SalesTable using update_recordset with in While loop which is having looping same SalesTable instance

    Please verify and update us with more details

  • zhouminweizmw Profile Picture
    100 on at

    I thought I should change the salestype by hand.

  • zhouminweizmw Profile Picture
    100 on at
    //the class
    class OP_TestSalesOrderConfirmtionCreater extends RunBaseBatch
    {
    
    }
    //method list in this calss 
    protected boolean canGoBatchJournal()
    {
        return true;
    }
    
    public void run()
    {
        SalesTable  salesTable,salesTableUpd;
        List soids=new List(Types::String);
        ListEnumerator so=null;
        ;
        soids.addEnd('SO-000060');
        soids.addEnd('SO-000061');
        soids.addEnd('SO-000062');
        //...a lots of salesid
        so=soids.getEnumerator();
        while(so.moveNext() )
        {
            update_recordset salesTableUpd
            setting
            SalesType =SalesType::Sales
            where salesTableUpd.SalesId ==so.current();
        }
    }
    
    server static void main(Args args)
    {
        OP_TestSalesOrderConfirmtionCreater SalesOrderConfirmtionCreater;
        ;
        salesOrderConfirmtionCreater = new OP_TestSalesOrderConfirmtionCreater();
        salesOrderConfirmtionCreater.run();
    }

    The Error Exception when auto run in batch job. But i run it by hand  is correct.

    Microsoft.Dynamics.Ax.Xpp.ErrorException: “Microsoft.Dynamics.Ax.Xpp.ErrorException”Exception。
       at Microsoft.Dynamics.Ax.MSIL.Interop.throwException(Int32 ExceptionValue)
       at Microsoft.Dynamics.Ax.MSIL.cqlCursorIL.UpdateAll(IntPtr table)
       at Dynamics.Ax.Application.OP_TestSalesOrderConfirmtionCreater.Run() position OP_TestSalesOrderConfirmtionCreater.run.xpp:line 20
       at Dynamics.Ax.Application.BatchRun.runJobStaticCode(Int64 batchId) position BatchRun.runJobStaticCode.xpp:line 54
       at Dynamics.Ax.Application.BatchRun.runJobStatic(Int64 batchId) position BatchRun.runJobStatic.xpp:line 13
       at BatchRun::runJobStatic(Object[] )
       at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)
       at BatchIL.taskThreadEntry(Object threadArg)


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
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans