Category: Dynamics 365 F&O Codes

D365 : MULTI-SELECT LOOKUP FOR SSRS REPORT DIALOG

WRITTEN BY MUHAMMADANASKHANDECEMBER 12, 2014 Overview: In this post we’ll learn how to build multi-select lookup for SSRS report dialog. We’ll create an RDP report with an AutoDesign layout. Controller will be used to run the report. An output menu item will be created to point to the controller class. Each AOT element involved will be…

D365FO | Ax2012: Create Counting Journal X++

public void CreateCountingJournal(JournalDescription _journalDescription, ItemId _itemId, InventQtyCounted _countedQuantity) { JournalCheckPost journalCheckPost; InventDim inventDim; InventDimParm tmpInventDimParm; InventJournalTrans journalTrans; InventJournalTable inventJournal; InventJournalName inventJournalName; JournalTableData journalTableData; InventSum inventSum; NumberSeq numberSeq; NumberSeq num; str journalName; str journalNum; int lineNum = 0; boolean errors; ; journalName = InventParameters::find().CountJournalNameId; num = new NumberSeq(); num = NumberSeq::newGetNum(InventParameters::numRefInventJournalId()); journalNum = num.num(); inventJournalName =…

D365FO: Create Counting Journal X++

public void CreateCountingJournal(JournalDescription _journalDescription, ItemId _itemId, InventQtyCounted _countedQuantity) { JournalCheckPost journalCheckPost; InventDim inventDim; InventDimParm tmpInventDimParm; InventJournalTrans journalTrans; InventJournalTable inventJournal; InventJournalName inventJournalName; JournalTableData journalTableData; InventSum inventSum; NumberSeq numberSeq; NumberSeq num; str journalName; str journalNum; int lineNum = 0; boolean errors; ; journalName = InventParameters::find().CountJournalNameId; num = new NumberSeq(); num = NumberSeq::newGetNum(InventParameters::numRefInventJournalId()); journalNum = num.num(); inventJournalName =…

AX 2012 | D365: Post Packing Slip using X++

static void postPackingSlip(Args _args) { SalesFormLetter salesFormLetter; SalesTable salesTable; SalesId salesId = ‘SO00001’; System.Exception error; str strError; CustPackingSlipJour custPackingSlipJour; ; ttsBegin; try { salesTable = SalesTable::find(salesId); if (salesTable && salesTable.SalesStatus == SalesStatus::Backorder) { salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip); salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::PackingSlip, AccountOrder::None, NoYes::No, NoYes::No, NoYes::No); if (salesFormLetter.parmJournalRecord().TableId == tableNum(custPackingSlipJour)) { custPackingSlipJour = salesFormLetter.parmJournalRecord(); info(strFmt(‘New Packing Slip #:%1…

AX 2012 | D365: Post Sales Invoice using X++

static void postSalesInvoice(Args _args) { SalesFormLetter salesFormLetter; SalesTable salesTable; SalesId salesId = ‘005063’; System.Exception error; str strError; CustInvoiceJour custInvoiceJour; ; ttsBegin; try { salesTable = SalesTable::find(salesId); if (salesTable && salesTable.SalesStatus == SalesStatus::Delivered) { salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice); salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::All, AccountOrder::None, NoYes::No, NoYes::No, NoYes::No, NoYes::Yes); if (salesFormLetter.parmJournalRecord().TableId == tableNum(CustInvoiceJour)) { custInvoiceJour = salesFormLetter.parmJournalRecord(); info(strFmt(‘Sales Order #:%1…

[D365] How to add a custom report type to print management setup X++

The simple way to add new report or new design of existing report in Print management Step-1 Create new class SLD_DemoSample Step-2 Find class PrintMgmtDocType in Application Explore and open in designer Step-3 find the delegate in PrintMgmtDocType class  Delegate name is  getDefaultReportFormatDelegate Step-4 Subscribe the event of above highlighted event in the newly created class Step-5 Now add the…

Event handler wihle processReport DP X++

class SalesConfirmDPEventHandler { [PostHandlerFor(classStr(SalesConfirmDP), methodStr(SalesConfirmDP, processReport))] public static void SalesConfirmDP_Post_processReport(XppPrePostArgs args) { MCRCustPaymTable custPaymTable; SalesConfirmDP dpInstance = args.getThis() as SalesConfirmDP; SalesTable salesTableLocal; MCRCustPaymTableTmp custPaymTableTmp; custPaymTableTmp = dpInstance.getMCRCustPaymTable(); salesTableLocal = SalesTable::find(dpInstance.parmCustConfirmJour().SalesId); while select custPaymTable where custPaymTable.RefTableId == salesTableLocal.TableId && custPaymTable.RefRecId == salesTableLocal.RecId { custPaymTableTmp.clear(); custPaymTableTmp.initValue(); custPaymTableTmp.TenderTypeId = custPaymTable.TenderTypeId; custPaymTableTmp.TenderTypeName = custPaymTable.displayName(); custPaymTableTmp.Amount = custPaymTable.Amount; custPaymTableTmp.insert(); }…

Pass Args as record from onclick event handler to menu item D365fo [X++]

/// <summary> /// /// </summary> /// <param name=”sender”></param> /// <param name=”e”></param> [FormControlEventHandler(formControlStr(DocuView, Print), FormControlEventType::Clicked)] public static void Print_OnClicked(FormControl sender, FormControlEventArgs e) { Args args = new Args() ; DocuRef _DocuRef ; FormRun _formRun = sender.formrun() as FormRun ; FormDataSource _ds ; _ds =sender.formRun().dataSource(1); _DocuRef = _ds.cursor(); args.record(_DocuRef); // calling menu item new MenuFunction(identifierstr(DocuViewPrint), MenuItemType::Action).run(args); }

Sending Email using X++ Code (AX2012/D365)

class SRSendEmail_D365 {     public static void main(Args _args)     {         SysMailerMessageBuilder messageBuilder = new SysMailerMessageBuilder();         Email   toEmail;         Email   fromEmail;         try         {             FromEmail = “sreddy@xyzcompany.com”;             toEmail   = “tester@xyzcompany.com”;             messageBuilder.setBody(“Hello from D365”, false);             messageBuilder.setSubject(“Email Test from D365”);             messageBuilder.addTo(toEmail);             // Note: not calling setFrom() defaults to the current user for SMTP client, whereas             // when sent to Outlook any setFrom() value will be ignored since profiles on the client are used             messageBuilder.setFrom(fromEmail);             //…