POST Agents/CRMScript/ExecuteScriptAsEventByUniqueId
Some tooltip text!
• 4 minutes to read
• 4 minutes to read
POST /api/v1/Agents/CRMScript/ExecuteScriptAsEventByUniqueId
Execute a CRMScript with event data as input.
Returns event data with output variable values. NsApiSlow threshold: 5000 ms.
Online Restricted: ## The CRMScript agent is not available in Online by default. Access must be requested specifically when app is registered.
Query String Parameters
| Parameter Name | Type | Description |
|---|---|---|
| $select | string | Optional comma separated list of properties to include in the result. Other fields are then nulled out to reduce payload size: "Name,department,category". Default = show all fields. |
POST /api/v1/Agents/CRMScript/ExecuteScriptAsEventByUniqueId?$select=name,department,category/id
Request Headers
| Parameter Name | Description |
|---|---|
| Authorization | Supports 'Basic', 'SoTicket' and 'Bearer' schemes, depending on installation type. |
| X-XSRF-TOKEN | If not using Authorization header, you must provide XSRF value from cookie or hidden input field |
| Content-Type | Content-type of the request body: application/json, text/json, application/xml, text/xml, application/x-www-form-urlencoded, application/json-patch+json, application/merge-patch+json |
| Accept | Content-type(s) you would like the response in: application/json, text/json, application/xml, text/xml, application/json-patch+json, application/merge-patch+json |
| Accept-Language | Convert string references and multi-language values into a specified language (iso2) code. |
| SO-Language | Convert string references and multi-language values into a specified language (iso2) code. Overrides Accept-Language value. |
| SO-Culture | Number, date formatting in a specified culture (iso2 language) code. Partially overrides SO-Language/Accept-Language value. Ignored if no Language set. |
| SO-TimeZone | Specify the timezone code that you would like date/time responses converted to. |
| SO-AppToken | The application token that identifies the partner app. Used when calling Online WebAPI from a server. |
Request Body: request
CRMScriptUniqueId, EventData
| Property Name | Type | Description |
|---|---|---|
| CRMScriptUniqueId | String | |
| EventData | EventData | EventData containing data related to event handlers |
Response:
OK
| Response | Description |
|---|---|
| 200 | OK |
Response body: EventData
| Property Name | Type | Description |
|---|---|---|
| Type | string | The type of event we are triggered by |
| InputValues | object | Environment values sent to the event handler |
| BlockExecution | bool | Whether the context should stop what it is doing, e.g. saving a sale |
| NavigateTo | string | Where the context should naviate afterwards |
| Message | string | A message to be presented to the user |
| ShowDialog | string | JSON structure of dialog to show |
| OutputValues | object | Values sent back to the environment from the event handler |
| StateValues | object | Values kept between event handlers |
| Exception | string | String containing error message from handler system if it failed |
| ParserValues | object | Parser values sent to the event handler |
| CgiVariables | object | Cgi variables sent by some events |
| CgiContent | string | The Cgi content/body, sent by some events |
| Headers | object | Incoming headers if sent by the context which the script is executed from |
| TraceExecution | bool | If true, then the execution will be traced |
| TableRight | TableRight | The carrier's table right |
| FieldProperties | object | Field property dictionary mapping field names to field access rights. |
Sample request
POST /api/v1/Agents/CRMScript/ExecuteScriptAsEventByUniqueId
Authorization: Basic dGplMDpUamUw
Accept: application/json; charset=utf-8
Accept-Language: en
Content-Type: application/json; charset=utf-8
{
"CRMScriptUniqueId": "provident",
"EventData": null
}
Sample response
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"Type": "ChatAfterSaveNewMessage",
"InputValues": {
"saleId": "54321",
"amount": "150000"
},
"BlockExecution": false,
"NavigateTo": "sale.main?id=54321",
"Message": "Sales opportunity score calculated and updated",
"ShowDialog": "Information",
"OutputValues": {
"calculatedScore": "85",
"scoringCriteria": "Customer value, Deal size, Timeline"
},
"StateValues": {
"saleStatus": "Qualified",
"lastScored": "2024-11-27T10:15:00Z"
},
"Exception": "",
"ParserValues": {
"scriptName": "sales-opportunity-scorer",
"executionTime": "92ms"
},
"CgiVariables": {
"HTTP_USER_AGENT": "SuperOffice/10.3",
"REMOTE_ADDR": "10.0.1.50"
},
"CgiContent": "{\"action\":\"score\",\"entity\":\"sale\"}",
"Headers": {
"Content-Type": "application/json",
"X-Script-Version": "1.2.0"
},
"TraceExecution": false,
"TableRight": null,
"FieldProperties": {
"fieldName": {
"FieldRight": null,
"FieldType": "System.Int32",
"FieldLength": 590
}
}
}