Methods used on the data source

Some data sources allow methods to be called on them using the InvokeMethod API. InvokeMethod takes the API name and an array of parameters. In the case of the Infor SyteLine data source, you must also pass the class where the method is found, which is the back office IDO name. To create the array of parameters, use the CreateMethodParameters API. The return value from the method is available unless the method did not execute correctly.

The general syntax of the InvokeMethod call is shown in this example:


Dim retVal As IPFMethodReturnValueI = 
   context.InvokeMethod("methodName", context.CreateMethodParameters(1, 2, 3))
If retVal.MethodCompleted = False Then
   ...do something with retval.Message...
End If

If the method supports output parameters, your script must maintain a reference to the parameter array or to the individual parameters, so that they can be accessed after the method completes successfully. For example, if the last positional parameter is an output parameter, use code similar to this:


Dim methodParms As IPFMethodParameterI() = context.CreateMethodParameters(1, 2, 
3)
Dim retVal As IPFMethodReturnValueI = 
   context.InvokeMethod("methodName", methodParms)
If retVal.MethodCompleted = False Then
   ...do something with retval.Message...
End If
...do something with methodParms(2).Value ....

Alternatively, the script could be written like this:


Dim outParm As IPFMethodParameterI = context.CreateMethodParameter("parmName", 
3)
Dim retVal As IPFMethodReturnValueI = 
   context.InvokeMethod("methodName", 
      context.CreateMethodParameters(1, 2, outParm))
If retVal.MethodCompleted = False Then
   ...do something with retval.Message...
End If
...do something with outParm.Value ....

If the method supports named parameters, the example above shows how they can be used. If the method does not support named parameters, names are ignored.

Using the parameters passed to it, CreateMethodParameters creates an IPFMethodParameterI object for each parameter and then returns the array. In most cases the value passed in is immediately packaged unchanged.

In these special cases, you must use CreateMethodParameters directly for each parameter, rather than creating an array:

  • IPFMethodParameterI objects or each IPFMethodParameterI in an array or list of IPFMethodParameterI are added to the array directly. They are not repackaged into a new IPFMethodParameterI object.

  • Similarly, an array or list of objects is expanded. The array or list itself is not passed as a single IPFMethodParameterI.

  • If a KeyValuePair<string, object> is passed in, the key is the name of the parameter and the object is the value.

  • If a Dictionary<string, object> is passed in, it is treated as a collection of named parameters. The dictionary is updated with any output parameters when the method completes successfully.