Question Execution
Advertencia
Esta página aún no se encuentra traducida al español.
Description
The Question Execution Data Model (COTQuestionExec) is part of COTQuestion within an exec
field, i.e., exec.onChange
, exec.onDisplay
, exec.preload
, exec.presave
, exec.postsave
, exec.validate
. This model holds data for a Javascript-automated question that runs within a component lifecycle stage. It specifies the parameters or context variables and source code used in Javascript-automated survey components.
graph LR;
S[COTSurvey] --> C1[COTSurveyChat #1]
S --> C2[COTSurveyChat #2]
C1 --> Q1T[COTQuestion - Field Label]
C1 --> Q1I[COTQuestion - Input Settings]
C2 --> Q2T[COTQuestion - Field Label]
C2 --> Q2I[COTQuestion - Input Settings]
Q2I --> QE[COTQuestionExec]
JSON Sample
{
"exec" : {
"validate" : {
"context" : "responses#self",
"src" : "function run() { const email = context['responses#self'][0] ; if (!email.match(/@/)) return [ { cmd: 'RESULT', result: false, value: 'The input must have an @' } ]; return [{ cmd: 'RESULT', result: true }]; }"
}
}
}
Fields
Field | Description | Type | Notes |
---|---|---|---|
context | Indicates the Cotalker Data Model or context from where to extract the data. | string | See Execution Context table below for more details. |
src | The Javascript code used for the automation | string | See the Coding Guide for details. |
Execution Context
Functions must be able to have access to some contextual variables: This context must be set so that the JS code has access to these variables. Format: KEY1#VALUE1,KEY2#VALUE2,...
Examples:
Context | Type |
---|---|
respones#self: | string |
responses#<identifier> | string |
user#me | COTUser |
user#responder | COTUser |
user#creator | COTUser |
user#<id> | COTUser |
group#self | COTGroup |
group#<id> | COTGroup |
channel#self | COTChannel |
channel#<id> | COTChannel |
property#channel | COTProperty |
property#user: | COTProperty |
property#<id> | COTProperty |
survey#self | COTSurvey |
survey#<id> | COTSurvey |
question#self | COTQuestion |
time#unixms | number |
location#latlon | string, e.g. (17.21323:21:21323) |
Additional Resources
- Question Exec: Overview and examples of Javascript-automated questions
- COTQuestion: Questions data model
- "Questions" REST API documentation: basic "Questions" API requests
- API documentation in Swagger: complete with data models (schemas)
- COTLang: use COTLang for extracting data from models in routines
- Triggers and Contexts: more information on using data models within routines
Help
- Cotalker Platform Community: post your questions or search for previous answers given in the forum