Item Rule Service and REST Functions

You can use these functions to access web services and REST APIs.

InvokeRestGet

Syntax:

InvokeRestGet(
rest_service_name, 
map_of_query_parameters, 
return_value_expression, 
http_header_map)

This function is for use with a REST service.

Calls the REST service registered as rest_service_name, passing map_of_query_parameters to the GET action and returning the value. The returned value can be used for both assignment and validation.

Use InvokeRestGet() when the REST service is registered in Application Composer without any tokens in its URL.

Arguments:

  • rest_service_name - The name used when registering the REST service in Application Composer.

  • map_of_query_parameters - A map containing the name/value pairs to be passed to the GET operation. You must use the ToMap() function to construct the pairs for this argument. For example, to pass a service parameter such as https://api.vision.com/products?id=CN97774, specify ToMap("id","CN97774").

  • return_value_expression - The path to the field from the REST response that should be returned as the value of the InvokeRestGet function. Spaces and semicolons aren't allowed in this value.

  • http_header_map - (optional) A map containing name/value pairs of HTTP headers that should be used for the request.

Example (without HTTP headers):

The following example passes the query parameter q=ItemNumber=Vision_root_01 to the GET action of the web service item_rest, and returns the value to the ItemDescription attribute of the first item:

InvokeRestGet("item_rest", ToMap("q", "ItemNumber=Vision_root_01"), "items[0].ItemDescription")

Example (with HTTP headers):

The following example performs the same service call, but specifies the language code KO:

InvokeRestGet("item_rest", ToMap("q", "ItemNumber=Vision_root_01"), "items[0].ItemDescription", ToMap("Accept-Language", "KO"))

Note that the q parameter supported by Oracle REST services requires specific escaping and formatting for certain characters and words. More information about this can be found in the topic on GET method endpoints in the Oracle Cloud Accessing Business Objects Using REST APIs guide. This requirement needs to be kept in mind when creating the value of the q parameter when calling InvokeRestGet(). You can use the Replace() function to perform character escaping such as replacing " in an attribute value with \".

ToMap

Note: This function is not supported for use on its own. It's used within the scope of functions such as InvokeRestGet() and updateCustomObjectValues().

Syntax:

ToMap(key_1, value_1, key_2, value_2, ..., key_n, value_n)

Within the scope of another function, creates a series of name/value pairs that can be passed as an argument to a function. Each pair is comprised of a key and a value.

Example:

For this set of name/value pairs:

ObjectName=Item
Principal=Person
Name=wilson.smith
OrganizationCode=V1
ItemClass=Root Item Class

The following example creates a map of the pairs that can be passed as a single argument:

ToMap("ObjectName", "Item", "Principal", "Person", "Name", "wilson.smith", "OrganizationCode", "V1", "ItemClass", "Root Item Class")

InvokeRestGetWithTokens

Syntax:

InvokeRestGetWithTokens(
rest_service_name, 
token_value1, token_value2, ... , token_value_n, 
return_value_expression)

This function is for use with a REST service.

Calls the REST service registered as rest_service_name, passing token_value1 and all the other values that should be passed in to the tokens in the REST service URL to the GET action, and returning the value into the field identified by return_value_expression.

Use InvokeRestGetWithTokens() when the REST service is registered in Application Composer with tokens in its URL.

Arguments:

  • rest_service_name - The name used when registering the REST service in Application Composer.

  • token_value1, ... , token_value_n - The values that should be passed in to the tokens in the REST service URL. The token values must be passed in in the same order that they occur in the URL

  • return_value_expression - The path to the field from the REST response that should be returned as the value of the InvokeRestGet function. Spaces and semicolons aren't allowed in this value.

Example:

The following example passes the values wilson.smith, Root Item Class, and V1, to the tokens of the web service data_security_rest_params, and returns the value to the GrantId attribute of the first item:

InvokeRestGetWithTokens("data_security_rest_params", "wilson.smith", "Root Item Class", "V1", "items[0].GrantId")

InvokeWebService

Syntax:

InvokeWebService("service_name", "function_name", input_argument1, input_argument2,...)

This function is for use with a SOAP service.

The names of a SOAP web service and its custom function are passed as quoted strings which can't include space characters. Item rules support only simple type parameters and not complex type parameters being passed to this function.

Returns a value produced by a custom function called through a web service. The web service function must return a single value, since this function doesn't accept more than one value.

Example:

InvokeWebService("ValidateSLN_Digit", "execute", [Item].[Tag AG].[SL No])

When a rule expression using InvokeWebService() is executed at runtime, InvokeWebService() calls the web service service_name, and passes the input payloads such as input_argument1 to the function function_name. The value returned from function_name is returned to the rule expression by InvokeWebService().

Before calling the function function_name in a rule expression, you must register the web service service_name, along with the credentials used to call the service.

Custom Function Calls in Web Services

You can use custom functions in rule expressions by first writing functions and creating a public web service that includes the custom functions, then using InvokeWebService() to call the custom functions.