Dynamics AX Blog - Dynamics AX 2012 - Page 14

RSS-Feed of this version
AX 2012: Building a DefaultDimension/LedgerDimensionBelow you'll find a code example of how to generate a RecId of type DefaultDimension for several dimensions. static void buildDefaultAndLedgerDimension(Args _args) { DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage; DimensionAttribute dimensionAttribute; DimensionAttributeValue dimensionAttributeValue; DimensionDefault dimensionDefault; LedgerDimensionAccount ledgerDimensionAccount; dimensionAttributeValueSetStorage = new DimensionAttributeValueSetStorage(); // BusinessUnit dimensionAttribute = DimensionAttribute::findByName('BusinessUnit'); if(dimensionAttribute) { dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, '069', false, true); dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue); } // CostCenter dimensionAttribute = DimensionAttribute::findByName('CostCenter'); if(dimensionAttribute) { dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, '010', false, true); dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue); } // Department dimensionAttribute = DimensionAttribute::findByName('Department'); if(dimensionAttribute) { dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, '024', false, true); dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue); } dimensionDefault = dimensionAttributeValueSetStorage.save(); // Merge main account and source dimension values and return RecId which can be used as ledgerDimension ledgerDimensionAccount = DimensionDefaultingService::serviceCreateLedgerDimension(DimensionStorage::getDefaultAccountForMainAccountNum("110110"), dimensionDefault); info(strFmt("Default dimension recId: %1", dimensionDefault)); info(strFmt("DefaultDimension (Source RecId): %1 LedgerDimension (Merged RecId): %2", dimensionDefault, ledgerDimensionAccount)); } |
Create a picking list-header for production orderThe following job creates a "header" for a picking list for a production order. static void createProdJournalTable_PickingList_III(Args _args) { ProdJournalCreate prodJournalCreate; prodJournalCreate = new ProdJournalCreate(); prodJournalCreate.parmProdId('P000188'); prodJournalCreate.parmJournalNameId( ProdJournalName::standardJournalName( ProdJournalType::Picklist, prodJournalCreate.parmProdId())); prodJournalCreate.initProdJournalTableData(ProdJournalType::Picklist); prodJournalCreate.usedProdJournalTable().insert(); prodJournalCreate.run(); } |
Post purchase order through codeWith the help of the following lines, I want to show how you can post a purchase order by code. static void postPurchaseOrder(Args _args) { PurchTable purchTable = PurchTable::find("000025"); PurchFormLetter purchFormLetter; purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder); purchFormLetter.update(purchTable, "", systemDateGet(), PurchUpdate::All); } |
Post sales order confirmation through codeWith the help of the following lines, I want to show how you can post a sales order confirmation by code. static void postSalesConfirmation(Args _args) { SalesTable salesTable = SalesTable::find("000747"); SalesFormLetter salesFormLetter; salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation); salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::All); } |
Post sales packing slip through codeWith the help of the following lines, I want to show how you can post a sales packing slip by code. static void postSalesPackingslip(Args _args) { SalesTable salesTable = SalesTable::find("000747"); SalesFormLetter salesFormLetter; salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip); salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::All); } |
Post sales invoice through codeWith the help of the following lines, I want to show how you can post a sales invoice by code. static void postSalesInvoice(Args _args) { SalesTable salesTable = SalesTable::find("000747"); SalesFormLetter salesFormLetter; salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice); salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::All); } |
|
|
|
|
|
|
Below is a sample of X++ code which can be used to check or post a report as finished journal for a production order. Changing the value of the Enum JournalCheckPostType controls if the journal is checked or checked and posted.