AX / D365FO – Calling Datasource modified() method programatically

This example shows hot to change Form datasource field value and call its modified() methods throught X++ code [FormControlEventHandler(formControlStr(CustOpenTrans, MarkTrans), FormControlEventType::Clicked)] public static void MarkTrans_OnClicked(FormControl sender, FormControlEventArgs e) { FormCheckBoxControl callerButton = sender as FormCheckBoxControl; FormRun form = callerButton.formRun(); FormDataSource taxWithholdTrans_ds = form.dataSource(formDataSourceStr(TaxWithholdTrans, TaxWithholdTrans)) as FormDataSource; FormDataSource custTrans_ds = form.dataSource(formDataSourceStr(CustTrans, CustTrans)) as FormDataSource; ProjInvoiceJour projInvoiceJour; … Continue reading AX / D365FO – Calling Datasource modified() method programatically

AX / D365FO – Get DataSource in a Form Control EventHandler Method

In Dynamics 365 for Operations you can react to the OnClicked event by copying the event handler method for the event and pasting the method into a class. Below is an example of an event handler method that reacts to the OnClicked event of a button on a form Create new Class and paste below … Continue reading AX / D365FO – Get DataSource in a Form Control EventHandler Method

AX – D365FO – Automatically refresh Form grid data after pressing Action Menu item button

Are you using an Action menu item to insert or modify some rows in a From data grid and you want to immediatly refresh grid data to see you changes? It's simple!! When you add your Action Menu item in form just set the "Auto refresh data" property to YES (like shown below) After the … Continue reading AX – D365FO – Automatically refresh Form grid data after pressing Action Menu item button

AX – D365FO – Calculate Withholding tax on a Sales order – X++

This is an example job of how to calculate withholding tax for a Sales order class WithholdingtaxJob { /// <summary> /// Runs the class with the specified arguments. /// </summary> /// <param name = "_args">The specified arguments.</param> public static void main(Args _args) { SalesLine salesLine; Map mapOfTaxesToCalculate = new Map(Types::Container, Types::Real); TaxWithholdOnItem_TH taxWithholdOnItem_TH; TaxWithholdGroupData taxWithholdGroupData; … Continue reading AX – D365FO – Calculate Withholding tax on a Sales order – X++

AX – D365FO – Calculate Withholding tax on a Purchase order – X++

This is an example job of how to calculate withholding tax for a purchse order class WithholdingtaxJob { /// <summary> /// Runs the class with the specified arguments. /// </summary> /// <param name = "_args">The specified arguments.</param> public static void main(Args _args) { PurchLine PurchLine; Map mapOfTaxesToCalculate = new Map(Types::Container, Types::Real); TaxWithholdOnItem_TH taxWithholdOnItem_TH; TaxWithholdGroupData taxWithholdGroupData; … Continue reading AX – D365FO – Calculate Withholding tax on a Purchase order – X++

AX / D365FO – Convert an amount into an amount with fixed 2 decimal places after the comma using NUMBERFORMAT() in Electronic reporting

In Electronic reporting if you want to convert an amount into an amount with fixed 2 decimal places after the comma you can use NUMBERFORMAT function Here is an example NUMBERFORMAT(model.Payments.InstructedAmount, "#.00") If the amount is 12.3 then the result will be 12.30 If the amount is 12 then the result will be 12.00

AX / D365FO – Run a batch job with a different user account

When you create a batch job by default the job is executed by the user who created it. If for some reason the user is disabled by a system administrator (for example because he leaves the company where he works) the jobs stop executing and disappear from the jobs form. In these cases to preserve … Continue reading AX / D365FO – Run a batch job with a different user account

AX / D365FO – how to hide or display an xml element based on a particular condition in Electronic reporting

If you want to hide or show an XML element tag depending on a particular condition you can use the "Enabled" button (see below) In this case I want to show the xml element if the customer name is not empty. So enter a condition that returns true if the name is set and false … Continue reading AX / D365FO – how to hide or display an xml element based on a particular condition in Electronic reporting

AX / D365FO – Change default company in X++

If you want to change the company during the code (i.e. in a Runnable class or a job) you can use changeCompany('xxx') command like shown in this example : public static void main(Args _args) { SalesLine salesLine; changeCompany('USMF') //Default company is now 'USMF'. { while select salesLine where salesLine.SalesId == 'XXX-002011' { // do something.... … Continue reading AX / D365FO – Change default company in X++