Generate financial report in X++

Purpose The purpose of this blog post is to demonstrate how can we generate a financial report in X++ and download it as a file. Product Dynamics 365 Finance. Description Please find the code snippet below which can be used to generate a financial report in X++. The code generates the report in XML format. … Continue reading Generate financial report in X++

D365: Send email in X++ using email templates

Product: Dynamics 365 for Finance and Operations Purpose: The purpose of this document is to demonstrate how we can send emails in X++ using built-in email templates. For demonstration purposes we'll be using standard email template CnfmOrder. This email template is used to send email to customer when a sales order is confirmed. Business requirement: … Continue reading D365: Send email in X++ using email templates

D365: Create lookup in X++

Product: Dynamics 365 for Finance and Operations Purpose: The purpose of this document is to demonstrate how we can create a lookup in X++ and attach it to an extension field added to the form extension of standard Sales order form. This is a good example to see how we can use event handling to … Continue reading D365: Create lookup in X++

D365: Reverse customer transaction in X++

Purpose: The purpose of this document is to demonstrate how we can reverse a posted customer transaction through X++. The code below can be used as a script to automate reversal of posted customer transactions. Product: Dynamics 365 for Finance and Operations Development: Please find below the code which can be used to reverse a … Continue reading D365: Reverse customer transaction in X++

AX 2012: Sales Order Posting Custom Validations

It is often a customer requirement to check for custom validations before posting a Sales Order. The best place to put your code for custom validations can be found below: Validations for Sales Table: AOT > Classes > SalesFormLetterProvider > checkHeading() For example, To check for custom field SalesTable.MAKBlocked, this is how custom validation should be added in … Continue reading AX 2012: Sales Order Posting Custom Validations

AX 2012: Using Temporary Table as Form’s Datasource

First add a method on the form to populate records in the temporary table: public LabelsTable populateRecords() { SysDictTable dictTable = new SysDictTable(tableNum(PurchLine)); SysDictField dictField; TreeNode treeNode; LabelsTable labelsTableLocal; // Temporary table (InMemory) FieldId fieldId = dictTable.fieldNext(0); while (fieldId) { dictField = dictTable.fieldObject(fieldId); if (dictField.isSql() && !dictField.isSystem() && dictField.name() != "Modified") { treeNode = dictField.treeNode(); … Continue reading AX 2012: Using Temporary Table as Form’s Datasource

AX 2012: Loop through all the fields of a table in X++

This is how we can loop through all the fields of a table in X++: static void Job1(Args _args) { SysDictTable dictTable = new SysDictTable(tableNum(PurchLine)); SysDictField dictField; TreeNode treeNode; FieldId fieldId = dictTable.fieldNext(0); while (fieldId) { dictField = dictTable.fieldObject(fieldId); if (dictField.isSql() && !dictField.isSystem()) { treeNode = dictField.treeNode(); info(strFmt("%1 | %2 | %3", dictField.name(), // Field … Continue reading AX 2012: Loop through all the fields of a table in X++

AX 2012: evalBuf – Evaluate string expression in X++

evalBuf Function is a very strong API in X++. We can quite easily evaluate complex algebraic expressions given in string and the result is also given back in string. This API should be used along with CodeAccessPermission. The downside of using this API is that the code using this function is not supported in CIL. … Continue reading AX 2012: evalBuf – Evaluate string expression in X++

AX 2012: Add dynalink in X++

Use the following code to add dynalink to the form datasource query: public void init() { super(); this.query().dataSourceTable(tableNum(MzkPurchTrackingDetailsTable)).clearDynalinks(); this.query().dataSourceTable(tableNum(MzkPurchTrackingDetailsTable)).addDynalink( fieldNum(MzkPurchTrackingDetailsTable, PurchId), PurchParmTable, fieldNum(PurchParmTable, PurchId)); } Where, First parameter is the source table field Second parameter is the destination table Third parameter is the destination table field