Configuring Bound Functions
The framework supports configuring functions that are bound to entities. A function bound to an entity is invoked on an instance of the entity. In OData protocol, a bound function is considered to be an operation that does not change the state of an entity instance on which it is invoked. After the bound function is configured, it is invoked by a GET request to the URL:
<Domain Root>/<Entity Set>(<key>)/<Bound Function Name>(<param1>=<value1>, <param2>=<value2>)
* 
When you implement custom functions ensure that the function does not create, update, or delete data. The function should only read and retrieve data. Functions that write or update data can cause unexpected data creation or modification in Windchill.
A bound function is configured in the same way as an unbound function, except for the following differences:
A bound function is specified in the functions collection property in the <Entity JSON> file.
While specifying the function in the <Entity JSON> file, the property includeInServiceDocument is not applicable to bound functions. This is because bound functions cannot be included in the service document available at the domain root.
The first parameter in the function specification is called the binding parameter. The parameter must be of the same type as the entity that is bound to the function. This is a required parameter.
The function names defined in the <ENTITY>.js file start with function_.
Following are the configuration options for the properties of a bound function:
name—Name of the bound function, defined in camel case.
type—OData type of the parameter. The parameter can be a primitive, complex, or an entity type.
description—Short description of the function. The value will be displayed as an annotation (“Core.Description”) in the EDM.
parameters—JSON array specifying the list of parameters for the bound function. Each parameter has the following configuration options:
name—Name of the parameter in camel case.
type—OData type of the parameter. The parameter can be a primitive, complex, or an entity type.
isNullable—Specifies whether the parameter can be omitted in the request.
isCollection—Specifies whether the parameter takes one (false) or multiple (true) values.
* 
The bound function must have at least 1 non-null parameter for the entity it’s bound to. If there are more than 1 parameter, then the first parameter is the binding entity and is non-nullable.
For example, a bound function on Part, will always have at least the following parameter:
{
"name":"TheBindingParameterForTheFunction",
"type":"Part",
"isNullable":false
}
returnType—Information about OData type returned by the Function. Specify the following properties for the return types:
type—OData type returned by the function. Can be an OData primitive, Complex Type, or Entity.
isCollection—Specifies if the function returns one (false) or multiple (true) values.
Was this helpful?