Change request approval to evp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
answer = {
u_svp_approval_mandatory: false,
u_svp_no_vp: false,
u_evp_approval_mandatory: false // Add EVP approval flag
};
var svp_approval_required = false;
var svp_no_vp_required = false;
var evp_approval_required = false;
var gr_conflict = new GlideRecord('conflict');
gr_conflict.addEncodedQuery("change=" + current.sys_id + "^type=blackout^schedule.ref_cmn_schedule_blackout.u_svp_approval_req=true");
gr_conflict.query();
if (gr_conflict.next()) {
if (current.assigned_to.u_management_level < 5 && current.assigned_to.manager && current.assigned_to.manager.u_management_level < 6) {
svp_approval_required = true;
}
if (!current.assigned_to.u_vp && current.assigned_to.u_director && current.assigned_to.u_director.manager && current.assigned_to.u_director.manager.u_management_level == 6) {
svp_no_vp_required = true;
}
// Trigger EVP approval if no VP and no SVP, and director's manager level above 6
if (!current.assigned_to.u_vp &&
!current.assigned_to.u_svp &&
current.assigned_to.u_director &&
current.assigned_to.u_director.manager &&
current.assigned_to.u_director.manager.u_management_level > 6) {
evp_approval_required = true;
}
}
if (svp_approval_required) {
if (!current.assigned_to.u_vp || !current.assigned_to.u_vp.manager) {
current.work_notes = "Current User doesn't have an SVP";
}
answer.u_svp_approval_mandatory = true;
}
if (svp_no_vp_required) {
answer.u_svp_approval_mandatory = false;
answer.u_svp_no_vp = true;
}
if (evp_approval_required) {
answer.u_svp_approval_mandatory = false;
answer.u_svp_no_vp = false;
answer.u_evp_approval_mandatory = true;
}
this is not triggering approvals to evp when vp and svp are empty how to modify this so that it should trigger approval to evp in the workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Bhavani1995 ,
The logic checks SVP first, and once it sets that SVP is required, it doesn't reach the EVP check.
Some of the fields you're checking (like director, director’s manager) might be missing or empty, so the condition to trigger EVP is never true.
Even if the condition is correct, the workflow might not be using the EVP flag properly to send the approval to an EVP.
Change the order of the checks
Make sure you check for EVP first, before checking SVP or anything else. That way, if EVP is needed, it won’t be overwritten.
// Set all approvals off by default
answer = {
u_svp_approval_mandatory: false,
u_svp_no_vp: false,
u_evp_approval_mandatory: false
};
// Look for blackout conflicts related to the change
var gr_conflict = new GlideRecord('conflict');
gr_conflict.addEncodedQuery("change=" + current.sys_id + "^type=blackout^schedule.ref_cmn_schedule_blackout.u_svp_approval_req=true");
gr_conflict.query();
if (gr_conflict.next()) {
var user = current.assigned_to;
// First: Check if EVP approval is needed
if (!user.u_vp && !user.u_svp &&
user.u_director && user.u_director.manager &&
user.u_director.manager.u_management_level > 6) {
answer.u_evp_approval_mandatory = true;
}
// Second: If no VP, but director's manager is SVP
else if (!user.u_vp &&
user.u_director && user.u_director.manager &&
user.u_director.manager.u_management_level == 6) {
answer.u_svp_no_vp = true; //
}
// Third: Standard SVP approval case
else if (user.u_management_level < 5 &&
user.manager && user.manager.u_management_level < 6) {
answer.u_svp_approval_mandatory = true;
}
}