Dynamic approvals in record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2024 04:37 PM
I have created RP in "sc_cat_item_producer" table with some variables in CSM module.
In variables there are two variables (department and tower).
I have a list of approval matrix for which I have created custom table(u_tower_matrix) with 3 fields (department, tower and approver).
I want, based on department and tower selected while raising case approval should trigger based on apporval matrix.
How I can achieve it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2024 07:34 PM
Hi @Hafsa1 ,
yo can create flow on csm table.
Add activity call lookup record, put condition for department and tower, which will return 1 record.
Add next activity ask for approval and the n approval group get it from lookup record from above step.
Accept and like the solution if it helped
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2024 02:04 AM
In table "u_tower_matrix", combination is based on variables which user select while raising case. IT's dynamic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2024 03:47 AM
You can do this using Script Include and Business Rule,
Create a Business Rule on the sc_cat_item_producer table to trigger when a record is created or updated. The Business Rule will fetch the approver(s) from the u_tower_matrix table and assign the approval dynamically.
Script Include:
var GetTowerMatrixApprovers = Class.create();
GetTowerMatrixApprovers.prototype = {
initialize: function() {},
getApprovers: function(department, tower) {
var approvers = [];
var gr = new GlideRecord('u_tower_matrix');
gr.addQuery('department', department);
gr.addQuery('tower', tower);
gr.query();
while (gr.next()) {
approvers.push(gr.approver.toString());
}
return approvers;
},
type: 'GetTowerMatrixApprovers'
};
Business Rule:
When to run: After Insert
(function executeRule(current, previous /*null when async*/) {
var approvers = new GetTowerMatrixApprovers().getApprovers(current.department, current.tower);
if (approvers.length > 0) {
var gr = new GlideRecord('sysapproval_approver');
for (var i = 0; i < approvers.length; i++) {
gr.initialize();
gr.sysapproval = current.sys_id;
gr.approver = approvers[i];
gr.state = 'requested';
gr.insert();
}
} else {
gs.addErrorMessage('No approvers found for the selected Department and Tower.');
}
})(current, previous);