Enabling a Report Writer document as a Word Template
Ok, this is directly or indirectly a Report Writer subject, but nonetheless a topic related to Report Writer. In this example, I take the General Posting Journal transaction document and enable it under Word Templates. However, this example will not develop the Word Template itself, but rather show how easy it is to make the journal document template enabled.
The steps are very simple and in fact, with a little bit of creativity, a developer could potentially write code that quickly enables critical reports.
To enable an existing Microsoft Dynamics GP report:
1. Register a trigger against the IsTemplateEnabledReport() function of the syReportLookup form. Template enabled reports can be selected in the Reports lookup window.
Startup
Note: You will need to save the Startup script first (CTRL+S), and compile the dictionary when the trigger processing function is implemented.
2. Now that we have our Startup script and the trigger registered, we can implement the trigger processing function. In this case, I have labeled this function glPostingJournalReport().
glPostingJournalReport()
Note: In the above code I am using the dictionary constant DYNAMICS for the product ID as our report belongs to the core dictionary. Also, rather than hardcoding the resource Id for the report, I am using SanScript's resourceid() function to obtain the resource Id for the report.
3. Open Dexterity Utilities to extract and autochunk your dictionary into a final product. The following are the settings I used for this particular project:
4. Drop your chunk file in the Dynamics GP folder and make sure that you can see your trigger in action in the Reports lookup window under Report Template Maintenance.
Now that we have won half the battle, I will show in my follow up post, how to actually implement the template and make it all work together.
Downloads:
Extracted dictionary - Click here
Chunk file - Click here
Until next post!
MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/
The steps are very simple and in fact, with a little bit of creativity, a developer could potentially write code that quickly enables critical reports.
To enable an existing Microsoft Dynamics GP report:
1. Register a trigger against the IsTemplateEnabledReport() function of the syReportLookup form. Template enabled reports can be selected in the Reports lookup window.
Startup
{ Created by Mariano Gomez, MVP This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 2.5 Generic license. } local integer l_result; pragma (disable warning LiteralStringUsed); l_result = Trigger_RegisterFunction(function IsTemplateEnabledReport of form syReportLookup, TRIGGER_AFTER_ORIGINAL, function glPostingJournalReport); if l_result <> SY_NOERR then warning "Trigger registration for General Posting Journal report failed."; end if; pragma (enable warning LiteralStringUsed);
Note: You will need to save the Startup script first (CTRL+S), and compile the dictionary when the trigger processing function is implemented.
2. Now that we have our Startup script and the trigger registered, we can implement the trigger processing function. In this case, I have labeled this function glPostingJournalReport().
glPostingJournalReport()
{ Created by Mariano Gomez, MVP This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 2.5 Generic license. } function returns boolean result; in 'Product ID' nProdID; in Resid nResID; if nProdID = DYNAMICS then {It's our report. Indicate that it is template enabled.} case nResID in [resourceid(report 'General Posting Journal')] result = true; end case; end if;
Note: In the above code I am using the dictionary constant DYNAMICS for the product ID as our report belongs to the core dictionary. Also, rather than hardcoding the resource Id for the report, I am using SanScript's resourceid() function to obtain the resource Id for the report.
3. Open Dexterity Utilities to extract and autochunk your dictionary into a final product. The following are the settings I used for this particular project:
Auto-Chunk and Product Information windows |
Reports Lookup window |
Now that we have won half the battle, I will show in my follow up post, how to actually implement the template and make it all work together.
Downloads:
Extracted dictionary - Click here
Chunk file - Click here
Until next post!
MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/
Comments
We did something similar for our clients but we created a table to hold the report name and product ID and then the script reads this to determine if the report should be enabled.
This allows different clients to enable the reports specific to them (include 3rd party reports).
Jon.
I'm curious when Part 2 is due out for this. I'm specifically looking for more information on how to implement with 3rd party dictionaries and the ability to assign those templates to a customer.