User-defined functions

In addition to the system-defined functions, you can use functions that have specifically been added to the application for use in calculated fields. The names of user-defined functions intended for use in calculated fields begin with the letters “RW” so they are recognized by the Report Writer.

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”.


To add a user-defined function to an expression, select the core the function is part of from the Core drop-down list. Once a core is selected, the Function drop-down list will become active. You can then select the desired user-defined function from the Function drop-down list. Click Add to add the function to the expression.

The Report Writer automatically adds the selected function to the expression enclosed in parentheses and preceded by the system-defined function FUNCTION_SCRIPT. This system-defined function is used only to process user-defined functions. It is added to the expression by the Report Writer, and can’t be added to the expression from the System-Defined Function drop-down list.

Once the user-defined function is added to the expression, add any needed parameters using the fields and constants tabs. Table fields, calculated fields and constants can be used as parameters for a user-defined function included in a calculated field. Be sure the parameters are placed before the closing parenthesis.

Be sure to add the appropriate number and type of parameters for the selected function. The Report Writer will not check the compatibility of the specified parameters until runtime.


To use a report field value as parameter for a user-defined function, create a calculated field with that report field as the only element of the calculated expression. Then, use that calculated field as the parameter for the user-defined function in another calculated field.


When a user-defined function in a calculated field is evaluated depends on the parameters that are passed to the function. If no parameters are passed to the user-defined function, the function will be evaluated one time when the report is run. If a table field or value based on a table field is passed as a parameter to the user-defined function, the function will be evaluated each time a new record is read from that table.

The RW_AccountNumber user-defined function is used to retrieve an account number based on an account index stored in a table. The following is the expression for the calculated field that uses this user-defined function is shown in the following illustration. Notice that the Account Index field from the Year-To-Date Transaction Open table is passed to the function.

FUNCTION_SCRIPT(RW_AccountNumber GL_YTD_TRX_OPEN.Account Index )

Using this user-defined function allows you to easily use an account number on a report without having to attach the Account Master table to the report.


Documentation Feedback