Here is another support case that was resolved simply and quickly using the Support Debugging Tool.
The customer was using Extender to add an additional comment to the inventory stock transfer transaction. They created an Extender ID "ST_COMMENTS" and used the Long String field type in Extender which is a 255 character string. This worked fine.
Then the customer wanted to include the Extender field on the posting reports. There is a Knowledge Base (KB) article that explains how to use a calculated string field and a user defined report writer function to return Extender to a report. click on the link below for more details:
The instructions are to use the rw_TableHeaderString() report writer function and pass through the following parameters:
So below is the definition of the Comment calculated field:
Comment = FUNCTION_SCRIPT( rw_TableHeaderString 3107 "ST_COMMENTS" Table.FieldName 0 1 )
To break the 255 character string into 4 lines of up to 80 characters each the following calculated fields were also created using the RW_ParseString() report writer function:
Comment1 = FUNCTION_SCRIPT( RW_ParseString Comment 80 1 )
Comment2 = FUNCTION_SCRIPT( RW_ParseString Comment 80 2 )
Comment3 = FUNCTION_SCRIPT( RW_ParseString Comment 80 3 )
Comment4 = FUNCTION_SCRIPT ( RW_ParseString Comment 80 4 )
In theory this should work perfectly. In practice it fails badly.
The problem is that there currently is a 80 character limit on the size of string calculated fields in report writer. This limit is discussed in the following post: Hybrid - Cheque Amount in Words Example and required additional code to be written to solve it for the one function: Announcing Report Writer Function RW_ConvertToWordsAndNumbersParse. The problem report number for the 80 character limit is PR 5239.
The end result was that only the first 80 characters of the Extender long string was returned and so only the first line of the 4 Comment lines was populated. It was at this point that the support case was logged.
This is discussed on the following KB Article, but I have a better solution... read on:
When I took the case, I suggested a number of possible workaround solutions (some supported and some not supported):
We settled on the fourth option as the customer did not want additional VBA or Dexterity code and went through the short process of setting up a shared location for the SDT setup file, point the SDT to that location and setting it as the Administrator controlled location and setting Advanced Mode on by default. The steps for this are detailed in the SDT User Guide Manual (Debugger.pdf) and in the FAQ.
So using Runtime Execute (Microsoft Dynamics GP >> Tools >> Support Debugging Tool >> Options >> Runtime Execute), we created a Script ID using the same name as our Extender ID. We then used the Helper Function button to select the helper function: Template for rw_TableHeaderString. The template code use used to read in the parameters stored by the SDT when the rw_TableHeaderString() report writer function is called and to write the parameter to return as the result.
All you need to do is write the code to take the input parameters and return the result desired. In our case we just needed to use the same function to get Extender to return the Long String field (all 255 characters), and then parse the resulting string into lines returning the requested line. We hardcoded the line length as 80 characters and used the unused parameter 4 to specify the line number to be returned.
ExtenderString = rw_TableHeaderString(3107, "ST_COMMENTS", MBS_Number, 0, MBS_Control);MBS_TableHeaderString = RW_ParseString(ExtenderString, 80, MBS_Type);
Below is a screenshot of the complete script in the Runtime Execute window as well as the script itself as text:
Runtime Execute Code
local string MBS_TableHeaderString;local string MBS_Number;local integer MBS_Type;local integer MBS_Control;local string MBS_String;
local string ExtenderString;
call with name "MBS_Param_Get" in dictionary 5261, "Number", MBS_Number;call with name "MBS_Param_Get" in dictionary 5261, "Type", MBS_String;MBS_Type = integer(value(MBS_String));call with name "MBS_Param_Get" in dictionary 5261, "Control", MBS_String;MBS_Control = integer(value(MBS_String));MBS_TableHeaderString = "";
{ Add your code below here }ExtenderString = rw_TableHeaderString(3107, "ST_COMMENTS", MBS_Number, 0, MBS_Control);MBS_TableHeaderString = RW_ParseString(ExtenderString, 80, MBS_Type);{ Add your code above here }
call with name "MBS_Param_Set" in dictionary 5261, "TableHeaderString", MBS_TableHeaderString;
The final step was to modify the report to call the ST_COMMENTS script in the Support Debugging Tool by changing the dictionary number from 3107 to 5261 and adding line number needed as parameter 4. The resulting calculated fields are shown below (changes in red):
Comment1 = FUNCTION_SCRIPT( rw_TableHeaderString 5261 "ST_COMMENTS" Table.FieldName 1 1 )
Comment2 = FUNCTION_SCRIPT( rw_TableHeaderString 5261 "ST_COMMENTS" Table.FieldName 2 1 )
Comment3 = FUNCTION_SCRIPT( rw_TableHeaderString 5261 "ST_COMMENTS" Table.FieldName 3 1 )
Comment4 = FUNCTION_SCRIPT( rw_TableHeaderString 5261 "ST_COMMENTS" Table.FieldName 4 1 )
So now when the report prints, it calls our script which in turn calls the Extender script to get the Long String fields, then our script parses the long string into lines and returns the individual line requested.
That's all folks.
[Edit] This example is now available as an attachement at the bottom of this article.
For more information on Report Writer functions have a look at these related posts:
Enjoy.
David
// Copyright © Microsoft Corporation. All Rights Reserved.// This code released under the terms of the // Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)
06-Dec-2011: Added Knowledge Base (KB) Article 927390 which mentions 80 character issue. Changed KB links to public URLs.
05-Mar-2012: Added Example code in attachment.
Posting from Mark Polino at DynamicAccounting.net
msdynamicsgp.blogspot.com/.../how-to-display-more-than-80-characters.html
Posting from Jivtesh Singh at About Dynamics, Development and Life
www.jivtesh.com/.../everything-dynamics-gp-30.html
Posting by Sivakumar Venkataraman at Interesting Findings & Knowledge Sharing
msdynamicstips.com/.../support-debugging-tool-customization-8-displaying-long-item-descriptions-on-sop-blank-invoice
PLEASE READ BEFORE POSTING
Please only post comments relating to the topic of this page.
If you wish to ask a technical question, please use the links in the links section (scroll down, on right hand side) to ask on the Newsgroups or Forums. If you ask on the Newsgroups or Forums, others in the community can respond and the answers are available for everyone in the future.