The Report Writer user-defined rw_SelectAddrLine function script is a very handy function that allows most Sales Order Processing documents to display addresses without those pesky blank lines in between say the first address line and the city, state, and zip code, especially when the second address line is empty.
For this explanation I will use the Bill To Address Lines on the Sales Blank Invoice Form, which is one of the most commonly modified reports throughout the system.
The current address lines on this report are predicated on 3 calculated fields (Bill To Address Line 1, Bill To Address Line 2, and Bill To Address Line 3). In turn, these calculated fields call a Dexterity script — the rw_SelectAddrLine script — that displays the address lines based on the parameters that are passed in. The implementation of this script is as follows:
This script returns the address line for the specified position wherein blank lines are suppressed. Parameters are passed in the same order as the address lines to be printed. City/State/Postal Code are combined to form a single line. The line returned is selected from the parameter list by position but only non-blank lines are counted when calculating the position. This effectively suppresses the printing of blank address lines, which could be seen in earlier versions on Microsoft Dynamics GP.
Example: sLine1 through sLine5 are typically used for the contact person and fields Address 1, Address 2 and Address 3. sLine7 could be used for Country. But there are no restrictions on the values that sLine1-sLine5 and sLine7 actually contain. However, the line6 parameters of City/State/Postal Code are passed to the standard formatting method and thus should conform accordingly (or all left blank). If no line exists on the report for a given input line, pass an empty string for that parameter.
What this means to you as a user is, if you want to add, say the Country, you could potentially modify Bill To Address Line 1, Bill To Address Line 2, and Bill To Address Line 3, as follows:
In addition you will need to create a Bill To Address Line 4 to account for the Country. Let me explain. As is, the line addresses are only designed to account for an Address 1, Address 2, and City, State and Zip on a third line. If there is no Address 2 line, then only 2 lines get displayed. However, if you include Country, then in the cases where there are 2 address lines then the Country will not be displayed. With this said, Bill To Address Line 4 will look something like this:
NOTE: The commas in this article are for readability sake, but in Report Writer these must not be included when calling a FUNCTION_SCRIPT.
Finally, to include the RM_Customer_Master_ADDR.Country field on the existing Bill To Address Line 1, Bill To Address Line 2, and Bill To Address Line 3, you will need to click on the last set of double quotes (“”) then click the Remove button then add the Country field by selecting the Customer Master Address File from the Resources drop-down. Select the Country field then click on Add.
For more information on this and other Report Writer functions, please visit David Musgrave’s blog and read up.
Until next post!
Mariano Gomez, MIS, MVP, MCP, PMP
Maximum Global Business, LLC