The Infolog

A blog of Dynamics AX development tips and tricks

Skip to: Content | Sidebar | Footer

Adding a range to the query that SalesEditLines form uses

12 June, 2015 (14:41) | Dynamics AX | By: Howard Webb

When posting an invoice, delivery note…etc. from a sales order a common form is used called SalesEditLines:

 

 

This form is quite complex and uses several framework classes to build itself and the data within it. Recently I was asked to add a new range to the query that builds the results in the form. To get this took quite some digging in to the classes behind the form. Like most complex forms it has a form class to do the more complex work. The class in this instance is \Classes\SalesEditLinesForm however we also have a number of children class where there can be custom code for each different instance of the form. Which of the children is used depends on the document status of the caller. To find out which is used you can put a breakpoint in \Classes\SalesEditLinesForm\construct.

Not only does this form use the above classes, it also uses the FormLetter framework which is what we are interested here as this will be the bit that creates the query we see within the form. AX will create an instance of \Classes\SalesFormLetter or one of its children again based off the document status. These classes all use a class (or a child of) called \Classes\SalesFormletterParmData.

 

Within our ParmData class there is a method called queryName, this will contain the AOS query that will be used to create the query. Below is an example of this method for a SalesInvoice:

 

 

While we could edit the AOS query, we would need to examine the impact of changing this and we cannot do this dynamically. To change the query via code we can place the code in the method updateQueryBuild. Below is an example found in the class for sales invoice.

 

 

We can access the query by using chooseLines.Query() and then change it as we please using the query classes and methods.

Print Friendly, PDF & Email

Comments

Comment from Roman
Time 16th March 2018 at 17:30

Thanks a lot! You saved me a a lot of time!