Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Thursday, August 20, 2015

X++ code to validate & post invent Journal in AX 2012

Hi,

static void AlfasithPostJournal(Args _args)
{ 
    InventJournalCheckPost      inventJournalCheckPost;
    InventJournalTable          inventJournalTable;
    ; 
    inventJournalTable = InventJournalTable::find("INV-0001245");
    inventJournalCheckPost = InventJournalCheckPost::newJournalCheckPost(JournalCheckPostType::Check, inventJournalTable);
    inventJournalCheckPost.parmThrowCheckFailed(true);
 // This true enable to prompt the error msg validate the journal
    try
    { 
        inventJournalCheckPost.run();
    }
    catch
    {
        info("The journal contains errors.");
    }
}
*************************************OR****************************************
static void AlfasithPostJournal(Args _args)
{ 
    InventJournalCheckPost      inventJournalCheckPost;
    InventJournalTable          journalTable;
    ; 
    journalTable= InventJournalTable::find("INV-0001245");
if(InventJournalCheckPost::newPostJournal(journalTable).validate()) InventJournalCheckPost::newPostJournal(journalTable).run();   
}

Regards,

No comments:

Post a Comment

SQL code to upate one Legal entity banner to all the legal entity in D365

 Hi, update companyimage set  companyimage.Image  = companyimageA.Image  from  ( select Image from companyimage where dataAreaid = 'USF...