DecisionTableAPI - Scoped, Global
-
- UpdatedJan 30, 2025
- 36 minutes to read
- Yokohama
- API reference
The DecisionTableAPI class enables you to access Decision Tables data in scoped and global server-side scripts.
To access DecisionTableAPI methods, use the sn_dt
namespace. You must have the decision_table_crud_api role to use this API. To learn more about
Decision Tables, see Decision Tables.
DecisionTableAPI - DecisionTableAPI()
Instantiates a DecisionTableAPI object.
Name | Type | Description |
---|---|---|
None |
Example
DecisionTableAPI - createAnswerElementChoices(String decisionID, Array questions)
Creates multiple records in the Choices [sys_choice] table that are linked to answer elements.
Example
This example creates two choices for an answer element.
Output:
DecisionTableAPI - createAnswerElements(String decisionID, Array answerElements)
Creates multiple records in the Result [sys_decision_multi_result_element] table that are related to the specified decision table.
Example
This example creates two answer elements for a decision table.
Output:
DecisionTableAPI - createConditions(String decisionID, Array conditions)
Creates multiple records in the Decision Conditions [sn_decision_table_decision_condition] table that are related to the specified decision table.
Example
This example creates two decision conditions for a decision table.
Output:
DecisionTableAPI - createDecisionTable(Object decisionTable)
Creates a decision table record in the Decision Tables [sys_decision] table.
Example
This example creates an Emergency Change Policy decision table.
Output:
DecisionTableAPI - createInputChoices(String decisionID, Array choices)
Creates multiple records in the Choices [sys_choice] table that are linked to decision inputs.
Example
This example creates two choices for a decision input.
Output:
DecisionTableAPI - createInputs(String decisionID, Array inputs)
Creates multiple records in the Decision Inputs [sys_decision_input] table that are related to the specified decision table.
Example
This example creates two inputs for a decision table.
Output:
DecisionTableAPI - createQuestions(String decisionID, Array questions)
Creates multiple records in the Decisions [sys_decision_question] table that are related to the specified decision table.
Example
This example creates two questions for a decision table.
Output:
DecisionTableAPI - deleteAnswerElement(String answerElementID)
Deletes a record in the Result [sys_decision_multi_result_element] table.
Name | Type | Description |
---|---|---|
answerElementID | String | Sys_id of the answer element record. Table: Result Elements [sys_decision_multi_result_element] |
Example
This example deletes an answer element.
Output:
DecisionTableAPI - deleteChoice(String choiceID)
Deletes a record in the Choices [sys_choice] table.
Name | Type | Description |
---|---|---|
choiceID | String | Sys_id of the choice record. Table: Choices [sys_choice] |
Example
This example deletes a choice.
Output:
DecisionTableAPI - deleteCondition(String conditionID)
Deletes a record in the Decision Conditions [sn_decision_table_decision_condition] table.
Name | Type | Description |
---|---|---|
conditionID | String | Sys_id of the decision condition record. Table: Decision Conditions [sn_decision_table_decision_condition] |
Example
This example deletes a decision condition.
Output:
DecisionTableAPI - deleteDecisionTable(String decisionID)
Deletes a record in the Decision Tables [sys_decision] table.
Name | Type | Description |
---|---|---|
decisionID | String | Sys_id of the decision table record. Table: Decision Tables [sys_decision] |
Example
This example deletes a decision table.
Output:
DecisionTableAPI - deleteInput(String inputID)
Deletes a record in the Decision Inputs [sys_decision_input] table.
Name | Type | Description |
---|---|---|
inputID | String | Sys_id of the decision input record. Table: Decision Inputs [sys_decision_input] |
Example
This example deletes a decision input.
Output:
DecisionTableAPI - deleteQuestion(String questionID)
Deletes a record in the Decisions [sys_decision_question] table.
Name | Type | Description |
---|---|---|
questionID | String | Sys_id of the question record. Table: Decisions [sys_decision_question] |
Example
This example deletes a question.
Output:
DecisionTableAPI - getAll()
Returns all decision tables from the Decision Tables [sys_decision] table.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Object | All decision tables and their fields from the Decision Tables [sys_decision]
table. Each decision table contains these key-value pairs:
Format: JSON |
Example
Output:
DecisionTableAPI - getAnswers(String decisionID)
Returns the answers associated with the specified decision table. An answer is a record on any table associated with a Decision [sys_decision_question] record.
Name | Type | Description |
---|---|---|
decisionID | String | Sys_id of the Decision Table record from the Decision Tables [sys_decision] table. |
Type | Description |
---|---|
Object | Answer records associated with the decision table. Each record contains these
key-value pairs:
Format: JSON |
Example
Output:
DecisionTableAPI - getDecision(String decisionID, Map inputs)
Evaluates a decision table based on the provided inputs and returns an answer. If no inputs are provided, returns the first default answer found.
Name | Type | Description |
---|---|---|
decisionID | String | Sys_id of the Decision Table record from the Decision Tables [sys_decision] table. |
inputs | Map | Optional. Input values for the Decision Inputs [sys_decision_input] table associated with the provided decision table. Use the value of the Column name field as the key. The data type of
the value must match the Decision Input Type field. If no inputs are provided, returns the first default answer found. Note: All inputs and column names must follow the following format:
For example,
For more information, see Make Decisions from JavaScript with the DecisionTableAPI - Workflow Automation CoE |
Type | Description |
---|---|
GlideRecord | The correctly evaluated Answer record associated with the decision table. An answer record is a record from the table defined in the Decision [sys_decision_question] record Answer table
field.
|
Example
DecisionTableAPI - getDecisions(String decisionID, Map inputs)
Evaluates a decision table based on the provided inputs and returns all correctly evaluated answers. If no inputs are provided, returns all default answers.
Name | Type | Description |
---|---|---|
decisionID | String | Sys_id of the Decision Table record from the Decision Tables [sys_decision] table. |
inputs | Map | Optional. Input values for the Decision Inputs [sys_decision_input] table associated with the provided decision table. If no inputs are provided, returns all default answers. Note: All inputs and column names must
follow the following format:
For example,
For more information, see Make Decisions from JavaScript with the DecisionTableAPI - Workflow Automation CoE |
Type | Description |
---|---|
Array | List of answer records in GlideRecord format. An answer record is a record on
any table associated with a Decision [sys_decision_question] record.
|
Example
DecisionTableAPI - getDecisionTable(String decisionID)
Returns a single decision table from the Decision Tables [sys_decision] table.
Name | Type | Description |
---|---|---|
decisionID | String | Sys_id of the Decision Table record from the Decision Tables [sys_decision] table. |
Type | Description |
---|---|
Object | Decision table from the Decision Tables [sys_decision] table. Each decision
table contains these key-value pairs.
Format: JSON |
Example
Output:
DecisionTableAPI - getInputs(String decisionID)
Returns the decision inputs from the Decision Inputs [sys_decision_input] table associated with the passed in decision table.
Name | Type | Description |
---|---|---|
decisionID | String | Sys_id of the Decision Table record from the Decision Tables [sys_decision] table. |
Type | Description |
---|---|
Object | Decision inputs from the Decision Inputs [sys_decision_input] table associated
with the decision table. You can find the inputs associated with a decision table
using the Decision Inputs related list in the Decision Tables [sys_decision] table.
Inputs contain these key-value pairs.
Format: JSON |
Example
Output:
DecisionTableAPI - getQuestions(String decisionID)
Returns the decisions from the Decision [sys_decision_question] table associated with the passed in decision table.
Name | Type | Description |
---|---|---|
decisionID | String | Sys_id of the Decision Table record from the Decision Tables [sys_decision] table. |
Type | Description |
---|---|
Object | Decisions from the Decision [sys_decision_question] table associated with the
decision table. You can find the decisions associated with a decision table using
the Decisions related list in the Decision Tables [sys_decision] table. Decision
records contain these key-value pairs.
Format: JSON |
Example
Output:
DecisionTableAPI - updateAnswerElement(String answerElementID, Object answerElement)
Updates a record in the Result [sys_decision_multi_result_element] table.
Example
This example updates the label and comments for an answer element.
Output:
DecisionTableAPI - updateChoice (String choiceID, Object choice)
Updates a record in the Choices [sys_choice] table.
Example
This example updates the label, value, and order for a choice.
Output:
DecisionTableAPI - updateCondition(String conditionID, Object condition)
Updates a record in the Decision Conditions [sn_decision_table_decision_condition] table.
Example
This example updates a decision condition.
Output:
DecisionTableAPI - updateDecisionTable(String decisionID, Object decisionTable)
Updates a record in the Decision Tables [sys_decision] table.
Example
This example updates a decision table.
Output:
DecisionTableAPI - updateInput(String inputID, Object input)
Updates a record in the Decision Inputs [sys_decision_input] table.
Example
This example updates a decision input.
Output:
DecisionTableAPI - updateQuestion(String questionID, Object question)
Updates a record in the Decisions [sys_decision_question] table.
Example
This example updates a question record.
Output:
On this page
- DecisionTableAPI - DecisionTableAPI()
- DecisionTableAPI - createAnswerElementChoices(String decisionID, Array questions)
- DecisionTableAPI - createAnswerElements(String decisionID, Array answerElements)
- DecisionTableAPI - createConditions(String decisionID, Array conditions)
- DecisionTableAPI - createDecisionTable(Object decisionTable)
- DecisionTableAPI - createInputChoices(String decisionID, Array choices)
- DecisionTableAPI - createInputs(String decisionID, Array inputs)
- DecisionTableAPI - createQuestions(String decisionID, Array questions)
- DecisionTableAPI - deleteAnswerElement(String answerElementID)
- DecisionTableAPI - deleteChoice(String choiceID)
- DecisionTableAPI - deleteCondition(String conditionID)
- DecisionTableAPI - deleteDecisionTable(String decisionID)
- DecisionTableAPI - deleteInput(String inputID)
- DecisionTableAPI - deleteQuestion(String questionID)
- DecisionTableAPI - getAll()
- DecisionTableAPI - getAnswers(String decisionID)
- DecisionTableAPI - getDecision(String decisionID, Map inputs)
- DecisionTableAPI - getDecisions(String decisionID, Map inputs)
- DecisionTableAPI - getDecisionTable(String decisionID)
- DecisionTableAPI - getInputs(String decisionID)
- DecisionTableAPI - getQuestions(String decisionID)
- DecisionTableAPI - updateAnswerElement(String answerElementID, Object
answerElement)
- DecisionTableAPI - updateChoice (String choiceID, Object choice)
- DecisionTableAPI - updateCondition(String conditionID, Object condition)
- DecisionTableAPI - updateDecisionTable(String decisionID, Object decisionTable)
- DecisionTableAPI - updateInput(String inputID, Object input)
- DecisionTableAPI - updateQuestion(String questionID, Object question)