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.
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().
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()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
public static class DocQueryRangeUtil { #define.AllRangeValue('') // return all records #define.NoRangeValue('InvalidValue_654653135') // return no records (!* does not work) /// <summary> /// Returns true if executed in batch. Actually returns the query range value that filters all or no records. /// </summary> /// <returns>Query range value that filters all or no records.</returns> [QueryRangeFunction] public static str isRunningInBatch() { if (isRunningOnBatch()) return #AllRangeValue; else return #NoRangeValue; } /// <summary> /// Returns true if not executed in batch. Actually returns the query range value that filters all or no records. /// </summary> /// <returns>Query range value that filters all or no records.</returns> [QueryRangeFunction] public static str isNotRunningInBatch() { if (!isRunningOnBatch()) return #AllRangeValue; else return #NoRangeValue; } } |
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.
Hi,
we have tried above class and advance filter option .still not able to send print to printer.
we are not able to see in Documentrouting status.
Thanks in advance.
Thanks,
Harikrishna
Hi Harikrishna,
We have repeated the test on latest Docentric version and it works fine.
Please reach us on support@docentric.com and we can try to help you.