How to a business rule run once?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 05:53 AM
Hey guys I have a business rule and client script - I have it set to when there is an incident raised via portal/ desktop the user if in a member of group X will automatically be assigned to the assignment group A.
I do have that functionality however the problem now is that if they would like to reassign the ticket to someone else - the rule will keep running and assigning the incident to group X.
Typically I would use g_form.newRecords however this doesnt work for incidents raised in the portal.
I am fairly new to scripting so this might be easy to fix but any help would be appreicated
business rule
Client Script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 06:01 AM
Hello,
I'm not sure about your requirement but if you want to set Assignment group you can do it in BR so no need for client script, BR can run on 'Insert' and it will not work on 'Update'. check below
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 06:06 AM - edited 12-06-2022 06:07 AM
Hey @Musab Rasheed This wont work as the requirement is to only set the assignment group if they are a member of a specific group hence why I added this condition in the BR
g_scratchpad.membership = gs.getUser().isMemberOf('8bc1dc921b2b95d01f19848ae54bcb4b');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 06:15 AM
That's fine, since you are setting Assignment group add that in condition tab , simple, if you do with Client script then value won't be set but if you do with BR then value will be set directly then later on it can get changed.
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 06:29 AM
@Ibrahim Majad You can achieve the functionality by just creating a before (insert/update) business rule.
Write the following code in the new before (insert/update) business rule:
(function executeRule(current, previous /*null when async*/ ) {
if (gs.getUser().isMemberOf("GROUP X NAME HERE")) {
current.assignment_group = "<GROUP A SYS ID HERE>";
}
})(current, previous);
Note: Deactivate your business rule and client script
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023