Approval based on variable contains
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2023 01:57 AM
Hi,
I have a reference variable that has the reference of 'Business Unit' table.
I want the approval to go based on the Business unit contains, but it's not working for me.
In the User approval activity I am using advanced.
var answer = [];
if (current.variables.business_unit.indexOf("abc") > -1) {
answer.push(gs.getProperty('approval.one'));
} else {
answer.push(gs.getProperty('approval.two'));
}
Kindly assist
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2023 07:39 AM
Hi,
I have updated the script and used log statements but it's skipping the if statement and only executes the else statement.
var answer = [];
if (current.variables.business_unit.getDisplayValue().indexOf("abc") > -1) {
answer.push(gs.getProperty('approval.one'));
gs.log("Approver One: " + answer);
} else {
answer.push(gs.getProperty('approval.two'));
gs.log("Approver Two: " + answer);
}
As I mentioned earlier even if the business unit contains abc it is still going to the second approval user, also in the log it's showing the sysid of the second approver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2023 07:42 AM
Hi @Jake Adams
can you just check what value it is returning 'current.variables.business_unit.getDisplayValue().indexOf("abc")' by keeping this value in logs.
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2023 08:10 AM
Hi,
I have tried it and it's coming like this
var answer = [];
if (current.variables.business_unit.getDisplayValue().indexOf("abc") > -1) {
answer.push(gs.getProperty('approval.one'));
gs.log("Business: " + current.variables.business_unit.getDisplayValue().indexOf("abc"));
//gs.log("Approver One: " + answer);
} else {
answer.push(gs.getProperty('approval.two'));
//gs.log("Approver Two: " + answer);
gs.log("Businesssss: " + current.variables.business_unit.getDisplayValue().indexOf("abc"));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2023 08:14 AM
@Jake Adams I think its working fine right .
Business_unit value doesnt contains 'abc'. so it is going to else condition. what is the issue here.
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2023 08:38 AM
No
As per the selection the Business unit contains 'abc' so it is going to approver in the else part while it should go for the approver inside the if