axaptadynamics-ax-2009x++ax

How can I change the production status via code? (AX 2009)


I have to change the production status via code, but not from the ProdTable form. The problem that I have is, that the class ProdMultiRelease expects to be run from the ProdTable form. (Line 10: RunBaseMultiParm::initFromForm(prodMultiRelease,args);)

Update: Here are some additional informations. First I tried it with something like this:

static void Job1(Args _args)
{
    Args args;
    ProdTable prodTable;
    ;
    prodTable = ProdTable::find( 'PRD_00005166', true);
    args = new Args();
    args.record( prodTable );
    new MenuFunction( menuitemactionstr( ProdRelease ), MenuItemType::Action ).run( args );
}

But it doesn't work.

Now I have something like this:

static void startprod(Args _args)
{
    ProdTable           prodTable;
    ProdMultiStartUp    ProdMultiStartUp;
    ;
    prodTable.selectForUpdate(true);
    select prodTable where prodTable.ProdId =='0267_074';
    prodTable.ProdStatus = prodStatus::StartedUp;
    prodTable.update();
    info('done');
}

This works fine, but I don't know if there are problems with simply setting the status.

Update2: I think I'll do it with:

prodTable.autoUpdate(prodStatus::Released);

Solution

  • I think the best way is to do it with:

    prodTable.autoUpdate(prodStatus::Released);