- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
We have created a customized table for SLA request. For non technical and technical ticket if the request is raised for SC Task it should go for one approver If incident it should go for another approver. This SLA request already having a flow design based on the vendor and technical and non technical type. Do anyone have idea to implement on this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
You can use Flow Designer in ServiceNow to trigger when a record is created or updated on your custom SLA request table, then add conditions like if type == SC Task > Ask for Approval by approver A and else if type == Incident > Ask for Approval by approver B, and for each branch you can include an Update Record action to automatically mark the approval as approved or rejected (or skip the ask step entirely if it should auto approve)..........
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
ServiceNow Solution: Routing SLA Request Approvals Based on Ticket Type (SC Task vs Incident)
-------------------------------------------------
Objective
-------------------------------------------------
Implement SLA Request approval logic that routes to different approvers depending on whether the related ticket is an SC Task or an Incident, while maintaining existing vendor and technical/non-technical branching.
-------------------------------------------------
1) Data Model
-------------------------------------------------
Table: u_sla_request
Fields:
- u_task (Reference → task)
- u_vendor (Reference → vendor table)
- u_is_technical (Boolean/Choice)
- u_approval_policy (Reference → approval matrix row for audit)
Approval Matrix Table (u_sla_approval_matrix):
- u_ticket_table (Choice: incident, sc_task, etc.)
- u_is_technical (True/False)
- u_vendor (Reference)
- u_approver_type (Choice: user/group/role)
- u_approver_ref (Reference to sys_user/sys_user_group/sys_user_role)
- u_fallback_approver (optional)
- u_order (integer)
-------------------------------------------------
2) Detecting the Ticket Type
-------------------------------------------------
function getTaskTableName(taskSysId) {
if (!taskSysId) return '';
var gr = new GlideRecord('task');
if (!gr.get(taskSysId)) return '';
return gr.getRecordClassName(); // 'incident', 'sc_task', etc.
}
-------------------------------------------------
3) Subflow: Resolve SLA Approver
-------------------------------------------------
Subflow Name: Resolve SLA Approver
Inputs: task_sys_id, vendor, is_technical
Outputs: result (JSON string)
Script Step:
(function execute(inputs, outputs) {
var taskTable = getTaskTableName(inputs.task_sys_id);
var m = new GlideRecord('u_sla_approval_matrix');
m.addQuery('u_ticket_table', taskTable);
m.addQuery('u_is_technical', inputs.is_technical ? true : false);
if (inputs.vendor) m.addQuery('u_vendor', inputs.vendor);
m.orderBy('u_order');
m.setLimit(1);
m.query();
var result = { approverType: '', approverRef: '', policy: '' };
if (m.next()) {
result.approverType = m.getValue('u_approver_type');
result.approverRef = m.getValue('u_approver_ref');
result.policy = m.getUniqueValue();
} else {
result.approverType = 'group';
result.approverRef = gs.getProperty('x_app.default_approval_group', '');
}
outputs.result = JSON.stringify(result);
function getTaskTableName(sysId) {
var gr = new GlideRecord('task');
if (!gr.get(sysId)) return '';
return gr.getRecordClassName();
}
})(inputs, outputs);
-------------------------------------------------
4) Main Flow (u_sla_request)
-------------------------------------------------
Trigger: On create or on status update requiring approval.
Steps:
1. Validate u_task, u_vendor, u_is_technical fields.
2. Call Subflow “Resolve SLA Approver”.
3. Parse result:
var cfg = JSON.parse(outputs['Resolve SLA Approver'].result);
4. Use “Ask for Approval” step:
- If cfg.approverType == 'user' → Approvers = cfg.approverRef.
- If 'group' → Approvers = group, set rule as “Anyone” or “All”.
- If 'role' → Resolve users with that role dynamically.
5. After approval, advance SLA Request state; on reject, mark Rejected.
-------------------------------------------------
5) Minimal Alternative (Hardcoded)
-------------------------------------------------
(function execute(inputs, outputs) {
var taskTable = '';
var taskId = current.u_task + '';
if (taskId) {
var gr = new GlideRecord('task');
if (gr.get(taskId)) taskTable = gr.getRecordClassName();
}
if (taskTable == 'sc_task') {
outputs.approverUser = 'SC_TASK_APPROVER_SYSID';
} else if (taskTable == 'incident') {
outputs.approverUser = 'INCIDENT_APPROVER_SYSID';
} else {
outputs.approverUser = gs.getProperty('x_app.default_approver','');
}
})(inputs, outputs);
-------------------------------------------------
6) Adding Project Closures
-------------------------------------------------
Include the project table in the approval matrix (u_ticket_table = 'pm_project') with its approver. The same subflow handles all ticket types.
-------------------------------------------------
7) Governance & Best Practices
-------------------------------------------------
- Validate u_task before proceeding.
- Allow multiple approvers using u_approval_sequence if needed.
- Configure escalation via Flow timeout or fallback approver.
- Store applied policy (u_approval_policy) for auditing.
- Use ATF tests to validate each routing path.
-------------------------------------------------
😎 Why This Is Best Practice
-------------------------------------------------
- Avoids multiple branch-heavy flows.
- Future-proof and maintainable (matrix-driven).
- Easily supports new ticket types and vendors.
- Business teams can manage approvers without Flow edits.
-------------------------------------------------
TL;DR
-------------------------------------------------
1. Create an Approval Matrix table keyed by ticket type, vendor, and technical flag.
2. Build a Resolve Approver subflow that reads this matrix.
3. In the main SLA Request Flow, call the subflow, then use “Ask for Approval” with the returned user/group.
4. Scales to SC Task, Incident, Project closures, etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
You can use Flow Designer in ServiceNow to trigger when a record is created or updated on your custom SLA request table, then add conditions like if type == SC Task > Ask for Approval by approver A and else if type == Incident > Ask for Approval by approver B, and for each branch you can include an Update Record action to automatically mark the approval as approved or rejected (or skip the ask step entirely if it should auto approve)..........
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
ServiceNow – SLA Request: Route Approver by Ticket Type (SC Task vs Incident)
Goal
In custom SLA Request Flow, use a different approver based on ticket type (SC Task vs Incident), vendor, and technical flag.
Recommended Design – Approval Matrix + Subflow
1) Create u_sla_approval_matrix table
Fields:
- u_ticket_table (Choice: incident, sc_task)
- u_is_technical (Boolean)
- u_vendor (Reference)
- u_approver_type (user | group | role)
- u_approver_ref (Reference)
- u_order (Integer)
- u_fallback_approver (Reference, optional)
2) On u_sla_request, keep:
- u_task (Reference → task)
- u_vendor
- u_is_technical
- u_approval_policy (Reference → matrix row)
3) Create Subflow: “Resolve SLA Approver”
Inputs: task_sys_id, vendor, is_technical
Script Step:
(function execute(inputs, outputs) {
var table = '';
if (inputs.task_sys_id) {
var gr = new GlideRecord('task');
if (gr.get(inputs.task_sys_id)) table = gr.getRecordClassName();
}
outputs.task_table = table;
})();
Next Step: Lookup u_sla_approval_matrix where:
u_ticket_table = outputs.task_table
u_is_technical = inputs.is_technical
u_vendor = inputs.vendor
Return approver type + approver reference.
4) Main Flow
- Trigger: SLA Request created
- Subflow: Resolve SLA Approver
- Ask For Approval:
If type=user → approver_ref
If type=group → group sys_id
If type=role → resolve role members
Best Practices
- Store chosen policy row in u_approval_policy for audit.
- Add fallback and timeout settings.
- Keep rules in matrix to avoid branching script logic.
- Build ATF tests for Incident vs SC Task scenarios.
Summary
Maintain a small Approval Matrix keyed by (ticket type, vendor, is_technical). A Subflow resolves the correct approver, and Flow Designer triggers the Ask for Approval step dynamically.
