Join us Dec. 16 for The Community Hour, our first global virtual User Group event!

Help with a business rule

Jen11
Tera Expert

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? 

5 REPLIES 5

Voona Rohila
Tera Patron

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

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

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

 

Its_Azar
Mega Sage

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);