Help with a business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
I would like to create a business rule. The requirement is as follows: When a certain assignment groups are updated on sys_user_grmember table, i would like to automatically create a request using 'General Request' catalog item and assign the task a team. Can someone please help me with this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago - last edited 4 weeks ago
Hi @Jen11
Can you explain in detail of the requirement, Do you want to track add/remove of group members?
As per your question - you can write a BR Accordingly and trigger the catalog item from BR using Cart JS API
Refer below link
https://www.servicenow.com/docs/r/yokohama/api-reference/server-api-reference/c_CartJSScoped.html
For the Task creation, The flow attached to the catalog item should be configured to 'create catalog task' and assignment
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
4x ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
everytime a user is added or removed from the group, i'll like to create a request using the general request catalog item and assign it to a team
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Yes a BR works perfectly in this scenario as @Its_Azar mentioned
You can directly call Cart API from BR or create a flow which submits the catalog item and call that flow from script
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
4x ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi there @Jen11
Since you want a request created every time a user is added or removed from a group, the correct pattern is:
Business Rule on sys_user_grmember → detect add/remove
Trigger a Flow → submit the General Request catalog item
Let the catalog flow handle task creation and assignment'
(function executeRule(current, previous) {
var action;
if (current.operation() == 'insert') {
action = 'ADD';
} else if (current.operation() == 'delete') {
action = 'REMOVE';
} else {
return;
}
var inputs = {};
inputs.user = current.user.toString();
inputs.group = current.group.toString();
inputs.action = action;
var flowAPI = new sn_fd.FlowAPI();
flowAPI.startFlow('x_your_scope.create_general_request', inputs);
})(current, previous);
Kind Regards,
Azar
Serivenow Rising Star ⭐
Developer @ KPMG.
