ftos.context.response.setData
Starting with v24.3.0, this is renamed from setData to ftos.context.response.setData.
Passes a JSON object from a server automation script (triggered by a callAction function) to the result parameter of the client-side callback function. The JSON object is attached to the <result parameter name>.UIResult.Data property.
ftos.context.response.setData is compatible with callAction, callActionByName, callActionAsync, and callActionByNameAsync functions.
This is a routes method for business service components.
Syntax
function ftos.context.response.setData(dataSet: any): void
| Parameter | Description |
|---|---|
dataSet
|
JSON object containing key – value pairs for the data set you wish to pass to the client-side callback function. |
Examples
In this example:
- We call the addUser endpoint, which runs a server automation script that adds new users to the database.
- In the server automation script, we pass the user's firstName and lastName (John Doe) to the client-side callback function.
- The client-side callback function uses the response parameter to store the received result.
The addUser endpoint runs a script that includes the following code:
ftos.context.response.setData ({'firstName' : 'John', 'lastName' : 'Doe'});
The client-side automation script includes the following code:
ebs.callActionByNameAsync('addUser')
.then(function(response){
console.log('User ' + response.UIResult.Data.firstName + ' ' + response.UIResult.Data.lastName + ' successfully added.');
})