Good luck!
Dynamics AX solutions for issues I encounter as I develop for Dynamics AX - now Dynamics 365 Finance & Operations
Friday, October 30, 2020
Designing SSRS reports easier
Good luck!
Thursday, October 22, 2020
AX SSRS Report - How to modify parameter properties based on usage data values
I have a report type parameter that determines which parameters the report needs to run.
I created a new enum for the Report type, available options are Job Number or Invoice Number.
If the job number is selected there will be a start job number and end job number with labels "Starting number" and "Ending number." If Invoice Number is selected there will be a start invoice number and an end invoice number with the exact same labels.
Since the job number is the first enum, I decided to build the parameters as if Job number were selected. However, if the user selects invoice number and that is stored in usage data, the parameter screen would need to accommodate that and show the correct parameters based on the invoice number report type selection.
I created a UI Builder class to accomplish this. My report is already using a contract class to define the 5 parameters I need for the report, a controller class, and a DP class to process the report. In the build() method of the UIBuilder class, I add all the dialog fields I will need and then I set visible = false for the invoice start and end fields.
In the postRun() method (before the super()), I check the value of the reportType enum. PostRun() gets called after the usage data is stored in the field(s). If the reportType is InvoiceNumber, I set the jobstart/end fields to visible = false and the invoicestart/end fields to visible = true.
This works nicely.
I also had to override the modified method of the reportType parameter in order to change the parameters shown when the user modifies the report type. For this, I used the postBuild() method tell the system to override the modified() method and where to go to find the new logic for this method.
Ensure that you use the right form control for your field type. For example, my enum reportType is a comboboxcontrol. If your field is a string, you would need a FormStringControl. If your field is an Int you would need a FormIntControl, etc. Your modified() method will need to pass that same type of control as well.
Good luck!
Tuesday, July 21, 2020
D365 Visual Studio Application Explorer filters
Everyone should know that you can use: type:"form" to only find form type elements but if you add regular expressions to it, you can greatly limit the results returned.
For example, you can add: List$ to find only forms that end in the word List or you can add: ^Cust to only find forms that start with Cust.
My favorite is to find objects that start with one word (often the prefix we are using for customizations) and ends with another word. For example, to find all objects that start with MCA and end with the word TEST you can do: ^MCA.*Test$
I use this every single day!
Happy coding!
Friday, October 18, 2019
D365: warehouse locations data migration
This is odd because the wmslocation table, the entity and the staging table all have the Mandatory property set to "No" for this field.
While investigating, I found that in the WhsLocationBuild class, "createNewLocation()" method, the system sets wmsLocation.aisleid to '--' (yes, it's hard-coded, sigh).
Also, the data entity specifically checks that the field is filled in during the validateWrite() method. To get around this, I added:
'--' as WarehouseAisleId
to my script that exports the data out of my legacy application.
Hope this helps!
Tuesday, October 8, 2019
D365: getting a drop-down/lookup for a new field on a table
In TestTable, create an index with your GroupId field in it. It should not allow duplicates and it should be used as the primary and clustered index of your table.
Now go to the InventLocation table and create a new relation, choose foreign key relation as the type of relation you are adding. The related table should be TestTable and then choose your index that you created as well.
Once you save this, it will add a field to InventLocation for you and will also create an Index for you. If you want to allow duplicates in InventLocation, you will have to go to the index it created and set allowDuplicates to Yes. You can delete the index if you don't want it though.
That's it!
Wednesday, September 18, 2019
D365: Menu item cannot be opened
In the background there was also this little message saying that the system language was not set. This was happening in a Dev environment using the DAT company/legal entity.
I did a full DB sync and still got the errors. I ended up going to fill in the system language because the pop up was annoying me and that fixed the issue with the menu items.
The setting is under System Administration > Setup > System parameters.
Hope this helps!
Wednesday, September 4, 2019
Dynamics 365: Printing two reports (a docentric and ssrs report) at the same time
There was also a requirement that when the master bill of lading was printed that all the children bill of ladings should be printed as well.
I created my own controller class to handle the reports (it extends WmsBillofLadingController). Both the bill of lading and master used the same controller class. The "print" button on the bill of lading form triggered this controller class (main method).
Thursday, August 1, 2019
Dynamics 365 - Breakpoint will not be hit. Symbols have not been loaded. . .
Under Dynamics 365 > Options :
Make sure under the Dynamics 365 > Debugging section, make sure that "Load symbols only for items in the solution" is NOT checked.
So I did that, but still continued to get this error when attempting to debug.
There is another setting that you need to check.
It is in VS under Tools > Options. Go to the Debugging > Symbols section and make sure that Automatically load symbols for :
"All modules, unless excluded" is selected!
Friday, May 4, 2018
AX 2012: Adding a field to PurchLine and the PO confirmation report
1) Add fields to purchLine table
2) Add fields to purchPurchaseOrderTmp table - this is used by the PurchPurchaseOrder report
3) Add fields to purchLineHistory table - this is used by the PurchLineArchivedVersions View and Query
4) Update PurchLineArchivedVersions view - drag the new field from the PurchLineHistory datasource into the Fields node of the view. Compile the view.
5) Update PurchLineNotArchivedVersions view - drag the new field from the PurchLine datasource into the Fields node of the view. Compile the view.
6) Compile the PurchLineAllVersions view and Synchronize. The field should be available in the PurchLineArchivedVersions and PurchLineNotArchivedVersions datasources on this view. Drag the new field from the PurchLineArchivedVersions view into the Fields node of the PurchLineAllVersions view. Compile this view.
7) Go to the PurchLineAllVersions QUERY now. You have to manually add the new field to the PurchLineArchivedVersions and PurchLineNotArchivedVersions datasources of this query because the dynamic fields property is set to No. Steps 3-7 are all being done because the PurchPurchaseOrderDP (data provider) class uses the PurchLineAllVersions view to copy data to the tmp table, so you need your new field there for step 8.
8) Modify the setPurchPurchaseOrderDetails() method on the PurchPurchaseOrderDP class and add code there to copy your field from PurchLineAllVersions to the PurchPurchaseOrderTmp table. It will look something like:
purchPurchaseOrderTmp.NewField = purchLineAllVersions.NewField;
Now you have to modify the report in visual studio. This was tricky. When I tried to refresh the dataset of the report to see my new fields I got some errors about a parameter on the report. It said Element:PurchPurchaseOrder.Parameters.IsPurchConfirmationRequestJournal has already been defined.
I ended up having to delete the Report parameter (isPurchConfirmationRequestJournal) on the report in Visual studio and refresh the datasets. Refreshing the datasets recreated the report parameter properly.
Hope this helps!
Wednesday, July 8, 2015
Allowing the value of 0.00 on a form for a mandatory field that is variable type Real
Here is how I got around this. In the validate() method on the control (it has to be at the control level - if you also want it on the datasource, you can add it there too) I commented out the super() and just allowed it to return true (you can also call your own validateField() method here if you like). My field happened to have an edit method, so in the edit method I called validateField() and modifiedField() on the table. When modifiedField() returned, I checked the value of my field, if it returned from validate/modified successfully and it was still 0, then I set the showZero() property of the control on the form to true. This shows the user the 0 that they entered. Remember to set your control AutoDeclaration property to Yes so that you can use the field control in the code easily.
edit Field editField(boolean _set, Field _edtField)
{
;
if (_set)
{
Table.Field = _edtField;
if (Table.validateField(fieldNum(Table,Field)))
{
Table.modifiedField(fieldNum(Table, Field));
edtField = _edtField; // edtField is a global variable on the form
if(edtField == 0.0)
{
Field_Control.showZero(true);
}
}
}
return edtField;
}



