Check execution in batch in Print management in D365FO

We cannot check execution in batch in Print management setup in Dynamics 365 for Finance and Operations using built-in filtering, but having this as an option would allow us to set up for a report to be printed using different Print management settings, depending on whether or not the report is executed in batch. For example, our invoices could be emailed to the customers when we are posting sales orders in batch, while on the other hand they would only be previewed from Invoice journal, when we click the Use print management button.

Checking if execution takes place in batch in Print management conditions can be done only by creating a custom Query range utility method.

What are Query range utility methods

Query range utility methods can be used in Advanced filter dialogs (e.g. in Print management conditions), in the Filter pane and grid column header filters with the matches operator, and with AOT queries.

Check Microsoft tutorial about Advanced filtering and query syntax >>

Built-in Query range methods are static methods placed in the SysQueryRangeUtil class, and you can use them in query ranges, e.g. currentDate(), lessThanDate(int relativeDays = 0), currentUserId(), currentUserLanguage().

While in AX 2012 we would add a new custom Query range method to the SysQueryRangeUtil class directly, in D365FO we only need to decorate a wanted (static) method in our custom class with the QueryRangeFunction attribute.

Query range method for checking execution in batch

Due to limitations of using Query range methods in query ranges – they cannot be combined with Advanced query syntax (e.g. with ! – the Not equal operator), we needed to create two different methods:

  • DocQueryRangeUtil::isRunningInBatch()
  • DocQueryRangeUtil::isNotRunningInBatch()

Use isRunningInBatch() in Print management conditions

We can use the above two methods with any field of Text or Option type. Please note that we cannot use them in expressions and that they have to be enclosed with brackets:

(DocQueryRangeUtil::isRunningInBatch())

Thus, if you want that your current Print management setting for a report applies only when the report is executed in batch, add (DocQueryRangeUtil::isRunningInBatch()) as a range to any Text/Option field you are not using in the setting.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Docentric respects your privacy. Learn how your comment data is processed >>