User-defined Functions

This appendix describes the common user-defined functions that are available for use in calculated fields. The following functions are described:

 

A document with descriptions of the user-defined functions available for the Report Writer is found in the Microsoft Dynamics GP SDK in the “Procedures and functions” category. You can find the document by searching for “Report Writer”.


RW_Address

Most addresses in Microsoft Dynamics GP allow up to three address lines. In some cases, you may want to suppress the address lines that are empty, and have the remaining lines of the address move up to occupy the unused space. In earlier versions of the Report Writer, you needed several calculated fields to accomplish this. The RW_Address user-defined function provides this functionality with only four calculated fields, one for each line of the address. The function takes the following parameters:

in integer Line_Number
in string Line1
in string Line2
in string Line3
in string City
in string State
in string PostalCode

The Line_Number parameter indicates which line of the address the calculated field will be producing. The value ranges from 1 to 4. The remaining lines are string values that are used to pass address information into the function.

For example, the address information in the RM_Customer_MSTR table consists of the Address 1, Address 2, Address 3, City, State, and Zip fields. The following calculated field displays the first line of the address. Notice that the first parameter passed to the RW_Address function is the integer value 1, indicating this is the first line of the address. The remaining parameters pass in address information from the RM_Customer_MSTR table.

FUNCTION_SCRIPT(RW_Address 1 RM_Customer_MSTR.Address 1 RM_Customer_MSTR.Address 2 RM_Customer_MSTR.Address 3 RM_Customer_MSTR.City RM_Customer_MSTR.State RM_Customer_MSTR.Zip ) 

The following calculated field is used to display the second line of the address. Notice that the first parameter is the integer value 2, indicating this is the second line of the address. All of the other parameters remain the same.

FUNCTION_SCRIPT(RW_Address 2 RM_Customer_MSTR.Address 1 RM_Customer_MSTR.Address 2 RM_Customer_MSTR.Address 3 RM_Customer_MSTR.City RM_Customer_MSTR.State RM_Customer_MSTR.Zip ) 

The third and fourth calculated fields are similar. The only difference is the first parameter is either the integer value 3 or 4, indicating the third or fourth line of the address. When all of the calculated fields are complete, add them to the report layout in place of the standard address fields.

[spacer]

RW_CityStateZip

The RW_CityStateZip user-defined function strips the space from between the City, State, and Zip Code fields of an address. It takes the following parameters:

in string City
in string State
in string ZipCode

The following calculated field uses the function to remove the extra spaces from the City, State, and Zip fields retrieved from the RM_Customer_MSTR table:

FUNCTION_SCRIPT(RW_CityStateZip RM_Customer_MSTR.City RM_Customer_MSTR.State RM_Customer_MSTR.Zip )

RW_GetAccountNumber

The RW_GetAccountNumber user-defined function retrieves an account number based on the account index. This allows you to retrieve an account number without having to link the Account Master table to your report. The function takes the following parameter:

in string AccountIndex

The following example shows an account number being retrieved, based on the Account Index field from the Year-To-Date Transaction Open table.

FUNCTION_SCRIPT(RW_AccountNumber GL_YTD_TRX_OPEN.Account Index )


Documentation Feedback