change request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
answer = {
// Configure policy inputs here
u_svp_approval_mandatory : false,
u_svp_no_vp : false
};
var svp_approval_required = false;
var svp_no_vp_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)
//Change Coordinator is not VP or above and CC's manager is below SVP. Returns true for empty string and null.
{
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) {
//director's manager is SVP
svp_no_vp_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;
}
in the existing script if the assigned user has vp and no svp so it is triggering to evp
how to add this extra condition when assigned user has no svp and no vp it should trigger to evp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hello @Bhavani1995,
Kindly review the modified sample script and let me know whether it is useful.
// Configure policy inputs here
var answer = {
u_svp_approval_mandatory: false,
u_svp_no_vp: false,
u_evp_approval_mandatory: false // New field for EVP approval
};
var svp_approval_required = false;
var svp_no_vp_required = false;
var evp_approval_required = false;
// Query for blackout conflicts requiring SVP approval
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 assigned_to = current.assigned_to;
var assigned_manager = assigned_to.manager;
// Check if assigned_to and manager exist
if (assigned_to && assigned_manager) {
// Change Coordinator is not VP or above and manager is below SVP
if (gs.nil(assigned_to.u_management_level) || assigned_to.u_management_level < 5) {
if (gs.nil(assigned_manager.u_management_level) || assigned_manager.u_management_level < 6) {
svp_approval_required = true;
}
}
}
// Director's manager is SVP, but assigned_to is not VP
if (!assigned_to.u_vp && assigned_to.u_director && assigned_to.u_director.manager) {
if (assigned_to.u_director.manager.u_management_level == 6) {
svp_no_vp_required = true;
}
}
// New Condition: If assigned user has NO VP and NO SVP, trigger EVP approval
var has_vp = !!assigned_to.u_vp;
var has_svp = !!assigned_to.u_svp;
if (!has_vp && !has_svp) {
// Optionally, check if EVP exists in the chain
if (assigned_to.u_evp) {
evp_approval_required = true;
}
}
}
// Set output flags based on conditions
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;
}
// EVP approval condition
if (evp_approval_required) {
answer.u_evp_approval_mandatory = true;
// Optionally, add a work note
current.work_notes = "Current User doesn't have a VP or SVP, triggering EVP approval.";
}
return answer;
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks
Santosh.P
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
42m ago
Hi @Bhavani1995 ,
You’ll need to add an additional check in your script to specifically handle the case where both VP and SVP are missing. Right now, your conditions only cover SVP approval and the “no VP” scenario. You can introduce a new condition like this:
if (!current.assigned_to.u_svp && !current.assigned_to.u_vp) {
answer.u_evp_required = true;
current.work_notes = "Escalated to EVP because no VP and no SVP found.";
}
This ensures that when neither VP nor SVP is present, the workflow triggers EVP approval instead of falling into your existing SVP/VP logic.
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
32m ago
I have tried this condition but this is not working
if (!current.assigned_to.u_svp && !current.assigned_to.u_vp) {
answer.u_evp_required = true;
current.work_notes = "Escalated to EVP because no VP and no SVP found.";