if script - approval group script - workflow utah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 02:52 AM
Hi there
i currently have 5 ifscripts, i have mentioned 2 as per below
was wondering if could replace all 5 ifscripts with one script in the approval group
/ Set the variable 'answer' to a comma-separated list of group ids or an array of group ids to add as approvers.
if so please provide me with a example
Thank You
Levino
//
// For example:
// var answer = [];
// answer.push('id1');
// answer.push('id2');
answer = ifScript();
function ifScript() {
var request = current.variables.create_or_modify;
var requestType = current.variables.modifications_required;
var group = current.variables.existing_group_display_name;
var ourUser = gs.getUser();
ourUser = ourUser.getUserByID(current.opened_by);
if (request == 'Modify' && requestType == 'Add' && group == 'AAD_PowerApps_MarketingROI_Prod' && !ourUser.isMemberOf('PowerApps Marketing')) {
return 'yes'; // this takes the output to group approval activity
}
return 'no'; // this skips group approval activity and takes to next activity
}
answer = ifScript();
function ifScript() {
var request = current.variables.create_or_modify;
var requestType = current.variables.modifications_required;
var group = current.variables.existing_group_display_name;
var ourUser = gs.getUser();
ourUser = ourUser.getUserByID(current.opened_by);
if (request == 'Modify' && requestType == 'Add' && group == 'AAD_PowerApps_Future' && !ourUser.isMemberOf('PowerApps Future')) {
return 'yes'; // this takes the output to group approval activity
}
return 'no'; // this skips group approval activity and takes to next activity
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 04:53 AM - edited 02-11-2024 04:54 AM
Hello @levino,
It seems like your !ourUser.isMemberOf('PowerApps Future') condition is different in the second if Script.So you can merge code like below:
answer = ifScript();
function ifScript() {
var request = current.variables.create_or_modify;
var requestType = current.variables.modifications_required;
var group = current.variables.existing_group_display_name;
var ourUser = gs.getUser();
ourUser = ourUser.getUserByID(current.opened_by);
if (request == 'Modify' && requestType == 'Add' && group == 'AAD_PowerApps_MarketingROI_Prod' && !ourUser.isMemberOf('PowerApps Marketing') && && !ourUser.isMemberOf('PowerApps Future')) {
return 'yes'; // this takes the output to group approval activity
}
return 'no'; // this skips group approval activity and takes to next activity
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 03:54 PM
hi there
will the above work if the approval group is different and the evaluated condition is different?
Thanks
Levino