Export (0) Print
Expand All

Customizing tokens for emailing and printing reports [AX 2012]

Updated: January 8, 2014

Applies To: Microsoft Dynamics AX 2012 R2

In cumulative update 7 or later for Microsoft Dynamics AX 2012 R2, you can email reports to specific people by using tokens in the Print destination settings form. Tokens are strings delimited with @ signs, such as @<Job Title>@ or @<Purpose>@, that you can use instead of entering individual email addresses. Built-in functionality in cumulative update 7 or later for Microsoft Dynamics AX 2012 R2 lets you use tokens like @Staffing Specialist@ or @Billing@ to send a report to all workers with a particular job title or customer contacts with a particular purpose.

Reports that use print management that are intended for an external audience support both worker title tokens and customer/vendor purpose tokens. Reports that don’t use print management and are intended for an internal audience support only the worker title tokens.

Developers can also customize the functionality of the tokens used in the Print destination settings form for emailing reports to a list. For example, you can develop an additional customization to retrieve titles from an external address book and send a report to the list of addresses that is retrieved externally. You can also customize tokens to specify other print destinations by using print management. For example, you can use tokens to specify a printer based on location. In this scenario, a token such as @wh printer@ could be used to specify a warehouse printer.

To customize the token functionality, use the extension framework to create a class that extends the SRSPrintDestinationToken class.

For example, the following class declaration uses the SrsPrintDestinationTokensExtAttribute to indicate a custom class type to the framework.

[SrsPrintDestinationTokensExtAttribute('Custom')]
class CustomPrintDestinationTokens extends SrsPrintDestinationTokens
{
    //…
}

To understand how to customize or extend the functionality for processing tokens, you should first understand how the framework classes supplied for this purpose work.

The following classes for expanding tokens into email addresses all extend SRSPrintDestinationToken:

  1. PrintMgmtPrintDestinationTokens class handles contact purpose support for printer destination tokens.

  2. HcmWorkerPrintDestinationTokens class handles worker title support for printer destination tokens.

  3. SRSPrintDestinationNone handles non-token cases like regular email addresses.

These classes are chained together in the order above, so that if one class doesn’t recognize a type of token, it is passed on to the next class in the chain. Each class specifies the next link in the chain in its new method.

For external reports, which use print management, PrintMgmtPrintDestinationTokens is the first class in the chain. For internal reports, the chain starts with HcmWorkerPrintDestinationTokens.

The expandEmailToken method in PrintMgmtPrintDestinationTokens provides an example of how to pass a token onto the next link in the processing chain. If you develop a custom class to do your own token processing, it should work properly with the other classes in the chain.

For more information about how to insert tokens when you send a report as email, see Print or email a report.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft