Contents Hide
This is the function executed on a remote procedure call to a script server data source.
function executeRPC(functionName, paramNames, paramValues)
{
if (functionName == "GetAge")
{
return getAge(paramValues.get(0)) ;
}
ScriptSession.setError(1, "Unknown function") ;
throw "Unknown function" ;
}
Note:
paramNames, paraValues are the parameters defined by the Bright Software Project. They are an array of values and thus are accessed as such with the get() method.
functionName is the variable used to dictate the script behaviour, passed to the script within a Bright Software Project. It is a string value and therefore may be operated on as such.
This function returns a record set. In this case, if the functionName is "GetAge" it will call a subfunction named getAge() within the script, and return the relevant records.
This method throws an error using the ScriptSession object if the function name is not valid.
From the above executeRPC function, subfunctions may be defined and model appropriate functionality
function getAge(name)
{
// Create result
result = new ResultRPC() ;
// Pass the parameter back
result.setOutputParameter("FirstName", name) ;
result.setOutputParameter("Age", new Integer(44)) ;
return result ;
}
Note:
getAge(name) is the function defined and called in the executeRPC() function in Example 1.
result is a RPC result that is created to hold resulting output parameters.
setOutputParameter is used to return the output parameter values.