Using Decision Builder in ServiceNow using Flow Designer as well as Script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 03:09 AM
Table of Contents
Inputs
Conditions
Results
Decision Rows
Flow Designer
Script Include & Catalog Client Script
Catalog Client Script (onChange)
Script Include
Concept
A Decision Table in ServiceNow, part of the Decision Builder application, functions like an Excel sheet where:
Rows represent individual decision entries
Columns define input conditions and output actions
This allows you to manage complex logic in a structured, maintainable, and scalable format.
Background
Recently, I faced a requirement to:
Display Category, Subcategory, and Questions related to the subcategory on a form
Automatically set the Priority of a request based on the selected question
There were nearly 400 questions to handle, and I needed a solution that was scalable and easy to maintain even by non-technical users.
A Decision Table turned out to be the perfect fit.
Prerequisites
Decision Builder plugin activated
Access to Flow Designer (for server-side execution)
Basic understanding of GlideAjax (for client-side use)
Decision Table Structure
To set up the logic:
Inputs: Question (from the form)
Result Column: Priority (Low, Medium, High)
Conditions
If the question belongs to the High Priority list → set Priority = High
If it belongs to the Medium Priority list → set Priority = Medium
For all other questions → set default Priority = Low
Implementation Approaches
Approach 1: Use Flow Designer
Call the Decision Table using Flow Designer
Configure the flow to trigger on record creation
Use the Decision Table to evaluate input and set the priority field
Approach 2: Use Client Script & Script Include
Useful when you want to dynamically set priority on form change, without waiting for record creation.
Code Examples
Catalog Client Script – onChange
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('getDecisionChoice');
ga.addParam('sysparm_name', 'getChoices');
ga.addParam('sysparm_input', g_form.getValue("questions_related_to"));
ga.addParam('sysparm_id', g_form.getUniqueValue());
ga.getXML(getBPDParse);
function getBPDParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//alert(answer);
g_form.setValue("priority",answer);
}
//Type appropriate comment here, and begin script below
}
Script Include – getDecisionChoice
var getDecisionChoice = Class.create();
getDecisionChoice.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getChoices: function(input) {
var inputs = {};
inputs['u_question_related_to']= this.getParameter("sysparm_input");
//gs.info("question"+this.getParameter("sysparm_input"));
var dt = new sn_dt.DecisionTableAPI();
var response = dt.getDecision('2aa12c1ec338a210b5587453e4013116', inputs);
var result_elements = response.result_elements;
var u_priority = result_elements.u_priority.getValue();
//gs.info("priority"+u_priority);
return u_priority;
},
type: 'getDecisionChoice'
});
Conclusion
Using Decision Tables with Flow Designer or GlideAjax allows for a scalable and maintainable way to drive logic based on dynamic inputs like questions. This is especially helpful in catalog or case management scenarios where decision logic can change frequently and needs to be managed outside of complex scripts.One Issue which I have faced while Implementation is "My Question Choice" value is greater than 40 in some scenarios so it was not working for them so make sure if you are using "is one of" operator in Condition of decision builder input then max length of choice should be less than 40 and it should not include any commas.