- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2025 10:16 PM
Hi
i have a requirement in workflow,if logged in user is knowledge base manager or owner the approval should not go
so i wrote a script in workflow like below
Its working fine for owner ,but coming to managers as it is as a lock field (attached screenshot below) if we add multiple users it not working, and if we add single user its working fine
How can we edit the script to work fine for multiple managers here?
Please help to resolve this issue @Ankur Bawiskar @Dr Atul G- LNG @Shivalika
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2025 10:21 PM
in your script update as this in bold
if(currentUserID == owner || manager.indexOf(currentUserID) > -1)
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2025 10:26 PM
Hi @sri vijaya
It's a list collector variable.
So try below script, it'll give you the corrcet output.
answer = ifScript();
function ifScript() {
var manager = current.kb_knowledge_base.kb_managers.toString();
var manager_array = manager.split(","); //converting the list value into array
var owner = current.kb_knowledge_base.owner.toString();
var currentUserID = gs.getUserID();
if (currentUserId == owner || manager_array.indexOf(currentUserId) > -1) {
return 'yes';
} else {
return 'no';
}
}
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2025 10:44 PM - edited ‎04-27-2025 10:47 PM
Hello @sri vijaya ,
Change line #9 to:
if (currentUserID == owner || manager.includes(currentUserID)) {
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2025 10:21 PM
in your script update as this in bold
if(currentUserID == owner || manager.indexOf(currentUserID) > -1)
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2025 10:26 PM
Hi @sri vijaya
It's a list collector variable.
So try below script, it'll give you the corrcet output.
answer = ifScript();
function ifScript() {
var manager = current.kb_knowledge_base.kb_managers.toString();
var manager_array = manager.split(","); //converting the list value into array
var owner = current.kb_knowledge_base.owner.toString();
var currentUserID = gs.getUserID();
if (currentUserId == owner || manager_array.indexOf(currentUserId) > -1) {
return 'yes';
} else {
return 'no';
}
}
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2025 10:44 PM - edited ‎04-27-2025 10:47 PM
Hello @sri vijaya ,
Change line #9 to:
if (currentUserID == owner || manager.includes(currentUserID)) {
Regards,
Robert
