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 02:05 AM
Hi @Jake Adams
can you keep logs and check if it is entering the if loop and also is it storing the value in answer.
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 02:18 AM
so what's not working? what debugging did you perform so far?
are you sure both the properties have proper sysId of user/group?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2023 04:57 AM
Hi,
Even though the business unit contains abc it is still going to the second approval user.
Yes both the properties have the correct sysid of the user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2023 06:03 AM
what's your analysis after adding gs.info() statements?
since the variable is reference do this
var answer = [];
if (current.variables.business_unit.getDisplayValue().indexOf("abc") > -1) {
answer.push(gs.getProperty('approval.one'));
} else {
answer.push(gs.getProperty('approval.two'));
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader