- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 02:57 AM
Hi Team,
We have a requirement where new group only created when group name start with Serv_Notif_ and type is customer notification by user.
I have created a business rule which restricted when name not start with Serv_Notif_ and type is customer notification but its not working .
(function executeRule(current, previous /*null when async*/ ) {
var Name = current.name;
gs.addInfoMessage(Name);
var Type = current.type;
gs.addInfoMessage(Type);
if (Name.STARTSWITH('Serv_Notif_')^Type.LIKE('87a7c92a1b494150533699371d4bcbb5')){
gs.addInfoMessage("New Group Created");
} else {
gs.addErrorMessage("Please select Type as Customer notification and name start with Serv_Notif_");
current.setAbortAction(true);
}
// Add your code here
})(current, previous);
Can any one please help me here.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 03:09 AM
your BR should be before insert
Update with this script
(function executeRule(current, previous /*null when async*/ ) {
var Name = current.name;
var Type = current.type;
if (Name.toString().startsWith('Serv_Notif_') && Type.indexOf('87a7c92a1b494150533699371d4bcbb5') > -1){
gs.addInfoMessage("New Group Created");
} else {
gs.addErrorMessage("Please select Type as Customer notification and name start with Serv_Notif_");
current.setAbortAction(true);
}
// Add your code here
})(current, previous);
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 03:09 AM
your BR should be before insert
Update with this script
(function executeRule(current, previous /*null when async*/ ) {
var Name = current.name;
var Type = current.type;
if (Name.toString().startsWith('Serv_Notif_') && Type.indexOf('87a7c92a1b494150533699371d4bcbb5') > -1){
gs.addInfoMessage("New Group Created");
} else {
gs.addErrorMessage("Please select Type as Customer notification and name start with Serv_Notif_");
current.setAbortAction(true);
}
// Add your code here
})(current, previous);
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 05:51 AM - edited 09-07-2023 06:20 AM
Hi @Ankur Bawiskar - Thanks for helping me out here. i need one more help.
I need to add user to the group if type is customer notifications. i create an ACL when i add the condition that group.type is cutomer notification then edit button is omit on group table
I have created a create ACL on Group membership table and added particular role . when i add the conditon group.type is cutomer notification, edit button omits from group table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 06:20 AM
you can restrict it via BR as well
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 06:51 AM
Can you help me with the BR.?