Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

when the manager is requested the item then approval manager should be skip if not need approval

Abhimitrake
Tera Contributor
answer = ifScript();
var mgr = current.variables.requested_for;
var gr = new GlideRecord('sys_user');
gr.get(mgr.sys_id);
var ge = gr.manager.toString();
function ifScript() {
    if (ge == current.opened_by.toString()) {
        return 'yes';
    } else {
        return 'no';
    }
}
 
 
 
The script is working but reverse order, if the request opened by and requested by manager are different then skipping the approval, when requested by manager and  opened by same then moving forward  for approval
 
can anyone help me with this
3 REPLIES 3

brianlan25
Kilo Patron

I'm not sure I understand you logic. You are looking at a variable and then getting the variables manager and trying to compare it to the opened by. That would always be no because the opened by could be the manager but if you are trying to compare it to who is listed as there manager. Are you trying to make it so that if the open by is the manager of the person it is being submitted for then you can skip the approval? Also are you using a variable for who the items is requested for?

 

If that is the case a better way to do it would be to dot walk instead of doing a GlideRecords.

answer = ifScript();

function ifScript() {
	var reqForMgr = current.variables.requested_for.manager;
	var openedBy = current.request.opened_by;
    if (reqForMgr == openedBy) {
        return 'yes';
    }
    return 'no';
}

Abhimitrake
Tera Contributor

Hi @brianlan25 ,

 

Thanks for your help,

 

but this script:

answer = ifScript();


function ifScript() {
var reqForMgr = current.variables.requested_for.manager;
var openedBy = current.request.opened_by;
    if (reqForMgr == openedBy) {
        return 'yes';
    }
    return 'no';
}

skipping for all conditions.

 

When a catalog item is requested:

If Requested For’s manager = Opened By → skip manager approval
If Requested For’s manager ≠ Opened By → send manager approval

Right now:

 Dot-walking skips always
 GlideRecord works but logic feels reversed

This is happening

They is requested for actually a variable? If not it should be current.request_for.manager. This is working in my instance as this is how we have it setup but we are not using variables for the requested for as we are doing 2 step checkout.