Individual approval activity for each selected item in List collector. So that i can add other activities based on individual approvals

nithyamaruthu
Tera Expert

Hi,

I have a List collector field(Applications) in the form. 

The approver are different for each selected application and it was derived from master table.

Approval process begins after submitting the form. Here I can set all approvals in one approval user activity by selecting the advanced and writing script in Additional approvers script field. But in my case after each approval based on the selected application I have to add other activities such as Add user to AD. For some applications the user can get approval and added in the AD. But for other applications he selected he can not get approval so no need to add to AD.

As of now i tried switch case for list collector. But for this i have to check all the applications present in the list collector table. It is not a good practice. I like to have some looping concept where for first selected item i can create a approval activity and then if approved a Add user to AD activity. then for second item, etc. till the length of the selected items. But all of the above should be parallel.

find_real_file.png

Instead of using the below case statement what else i can use?

find_real_file.png

1 ACCEPTED SOLUTION

nithyamaruthu
Tera Expert

Best practice is to split the request to multiple requested items with each list filter selection. And running workflow on each item.

 

find_real_file.png

I have used a Run script in the workflow to split the items.

 

generate();
function generate() {
//Sys IDs of Variables in the "Qlik Access Request" catalog item
var Requested_By='8ba1eee1db1d5f000194d36fdf9619e2';

var requested_behalf='d4cb4cd1db2197400194d36fdf96192f';

var Qlik_Appln='25431b01dbad57400194d36fdf96193b';

var unit='15895705dbad57400194d36fdf961920';

var tsu='319a1b85dbad57400194d36fdf9619cd';

var nau='90da9f05dbad57400194d36fdf96199e';

var fsu='2efa9b85dbad57400194d36fdf96197e';

var cci='560b9f85dbad57400194d36fdf96193b';

var ind='0f1b5f85dbad57400194d36fdf9619b6';

var cor='8b2b9b85dbad57400194d36fdf961985';

var Power_User='cf62662ddb1d5f000194d36fdf96197a';

var business_reason='9b479a9b133a57403b49fc04e144b0ae';

var subbusiness_unit='e8e89a9b133a57403b49fc04e144b0c3';


var listStr = current.variables.Qlik_Appln.toString(); //Variabile List Collector da Splittare


var list = listStr.split(',');


var IDritm;


for (var i = 0; i < list.length; i++) {


var ritm = new GlideRecord('sc_req_item');

ritm.initialize();
ritm.newRecord();


ritm.request = current.request;
ritm.cat_item ='d2e0eae9db1d5f000194d36fdf9619d3'; // updating Qlik Access Request

ritm.u_multiritm=true;

// ritm.variables.Qlik_Appln=current.variables.Qlik_Appln;
// ritm.variables.Requested_for=current.variables.Requested_for;
// ritm.variables.Power_User = current.variables.Power_User;
//ritm.allthefielduneed;



ritm.opened_by = current.opened_by;



var sysID = ritm.insert();

//Add variables to the Request Item


addVariable(sysID, Qlik_Appln,list[i],300);


addVariable(sysID, Requested_By,current.variables.Requested_By,100);


addVariable(sysID, requested_behalf,current.variables.requested_behalf,200);


addVariable(sysID, unit,'Please select the unit(s) for which you need access',400);


addVariable(sysID, tsu,current.variables.tsu,500);


addVariable(sysID, nau,current.variables.nau,600);


addVariable(sysID, fsu,current.variables.fsu,700);


addVariable(sysID, cci,current.variables.cci,800);
addVariable(sysID, ind,current.variables.ind,900);
addVariable(sysID, cor,current.variables.cor,1000);
addVariable(sysID,subbusiness_unit,current.variables.subbusiness_unit,1010);
addVariable(sysID, Power_User,current.variables.Power_User,1100);
addVariable(sysID,business_reason,current.variables.business_reason,1200);

//Start the workflow on all the created Items

startWf(current.request);

}
}


function addVariable(ritm,varID,value,order) {


var variable = new GlideRecord('sc_item_option');


variable.initialize();


variable.item_option_new = varID;


variable.value = value;


variable.order = order;


var sysID = variable.insert();



var itemm2m = new GlideRecord('sc_item_option_mtom');


itemm2m.initialize();


itemm2m.request_item = ritm;


itemm2m.sc_item_option = sysID;


itemm2m.insert();


}


function startWf(request) {


var ritm = new GlideRecord('sc_req_item');


ritm.addQuery('request',request);


ritm.addQuery('sys_id','!=',current.sys_id);


ritm.addNullQuery('context');


ritm.query();



while (ritm.next()) {


ritm.setForceUpdate(true);


ritm.update();


}


}

 

View solution in original post

7 REPLIES 7

OK i don't fully understand you requirements but if you need to return a different approver depending on the application then you could extend out your if statements to say 'if the application is x then assign approval to y'.

A more elegant and sustainable option might be to list the approver (and the AD group?) directly on the application record and then you can just glide into the app table, get(current.u_application) and then push the u_approver to the approval group. The AD group will then be available for your other requirements.

Like i said, i don't know the intricacies of what you're setting up here but, in terms of approval, using the scripted element in the approval record is the way to define different approvers in your workflow, you'll have to thrash out the fine details yourself 🙂

nithyamaruthu
Tera Expert

Best practice is to split the request to multiple requested items with each list filter selection. And running workflow on each item.

 

find_real_file.png

I have used a Run script in the workflow to split the items.

 

generate();
function generate() {
//Sys IDs of Variables in the "Qlik Access Request" catalog item
var Requested_By='8ba1eee1db1d5f000194d36fdf9619e2';

var requested_behalf='d4cb4cd1db2197400194d36fdf96192f';

var Qlik_Appln='25431b01dbad57400194d36fdf96193b';

var unit='15895705dbad57400194d36fdf961920';

var tsu='319a1b85dbad57400194d36fdf9619cd';

var nau='90da9f05dbad57400194d36fdf96199e';

var fsu='2efa9b85dbad57400194d36fdf96197e';

var cci='560b9f85dbad57400194d36fdf96193b';

var ind='0f1b5f85dbad57400194d36fdf9619b6';

var cor='8b2b9b85dbad57400194d36fdf961985';

var Power_User='cf62662ddb1d5f000194d36fdf96197a';

var business_reason='9b479a9b133a57403b49fc04e144b0ae';

var subbusiness_unit='e8e89a9b133a57403b49fc04e144b0c3';


var listStr = current.variables.Qlik_Appln.toString(); //Variabile List Collector da Splittare


var list = listStr.split(',');


var IDritm;


for (var i = 0; i < list.length; i++) {


var ritm = new GlideRecord('sc_req_item');

ritm.initialize();
ritm.newRecord();


ritm.request = current.request;
ritm.cat_item ='d2e0eae9db1d5f000194d36fdf9619d3'; // updating Qlik Access Request

ritm.u_multiritm=true;

// ritm.variables.Qlik_Appln=current.variables.Qlik_Appln;
// ritm.variables.Requested_for=current.variables.Requested_for;
// ritm.variables.Power_User = current.variables.Power_User;
//ritm.allthefielduneed;



ritm.opened_by = current.opened_by;



var sysID = ritm.insert();

//Add variables to the Request Item


addVariable(sysID, Qlik_Appln,list[i],300);


addVariable(sysID, Requested_By,current.variables.Requested_By,100);


addVariable(sysID, requested_behalf,current.variables.requested_behalf,200);


addVariable(sysID, unit,'Please select the unit(s) for which you need access',400);


addVariable(sysID, tsu,current.variables.tsu,500);


addVariable(sysID, nau,current.variables.nau,600);


addVariable(sysID, fsu,current.variables.fsu,700);


addVariable(sysID, cci,current.variables.cci,800);
addVariable(sysID, ind,current.variables.ind,900);
addVariable(sysID, cor,current.variables.cor,1000);
addVariable(sysID,subbusiness_unit,current.variables.subbusiness_unit,1010);
addVariable(sysID, Power_User,current.variables.Power_User,1100);
addVariable(sysID,business_reason,current.variables.business_reason,1200);

//Start the workflow on all the created Items

startWf(current.request);

}
}


function addVariable(ritm,varID,value,order) {


var variable = new GlideRecord('sc_item_option');


variable.initialize();


variable.item_option_new = varID;


variable.value = value;


variable.order = order;


var sysID = variable.insert();



var itemm2m = new GlideRecord('sc_item_option_mtom');


itemm2m.initialize();


itemm2m.request_item = ritm;


itemm2m.sc_item_option = sysID;


itemm2m.insert();


}


function startWf(request) {


var ritm = new GlideRecord('sc_req_item');


ritm.addQuery('request',request);


ritm.addQuery('sys_id','!=',current.sys_id);


ritm.addNullQuery('context');


ritm.query();



while (ritm.next()) {


ritm.setForceUpdate(true);


ritm.update();


}


}

 

Hi Nithya,

I have same requirement, just want to know where this script should write on Request's workflow?

Also OOB whenever we create any request, automatically 1 RITM gets created against that request so by this script that should not be created, right?