How to Bind an Argument to a JavaScript Function


Arguments defined for a Custom component, Grid component, UX component, or Report can be bound to the result of a JavaScript function when open opening the component or report using Action Javascript.


When you use Action Javascript to open a Grid, Report, UX Component, Custom Component, etc., you often need to bind the value of an argument to a value from the parent Component. For example, you might bind the value of "arg1" to the value of the Lastname field in the current grid row. In addition to binding an argument to the value of a field in the Grid, you can specify an arbitrary JavaScript function to execute. The argument is bound to the value that this Javascript function returns.

When specifying the value for the argument, you can specify a JavaScript function to call to populate the argument using the following syntax: Javascript:functionName. For example:


The JavaScript function will take rowNum as an argument. In the example function below, func1 function combines the first and last name for the current record in a Grid component into a single string. rowNum defines the currently selected record in the Grid component. Therefore, the function can use the parameter, rowNum, to get the value for 'FIRSTNAME' and 'LASTNAME' from the current record:

function func1 (rowNum) {
    var data = {grid.object}.getValue('G','FIRSTNAME',rowNum) + ' ' + {grid.object}.getValue('G','LASTNAME',rowNum);

    return data;

For full step-by-step instructions, watch the video below: