ServiceNow Business Rules allow you to respond to insert, query, update, and delete operations on ServiceNow tables. You can configure a Business Rule with a JavaScript script to send webhook events to Blink whenever the rule is triggered.

Configuring a ServiceNow Webhook

This guide explains how Admins can create a business rule. Non-admin users must be assigned the business_rule_admin role to create business rules.business_rule_roleFor more information on assigning roles to users, please visit our documentation.

Creating the Business Rule

  1. In the navigation filter (under the All tab), search for studio and click Studio under System Applications. Studio_View
  2. Select an application (or create a new one) to associate the Business Rule with. For more information on creating new applications, please visit ServiceNow’s Documentation. select_app
  3. On the next page, click Create Application File. create_app_file
  4. In the new file form, search for Business Rule and click Create. create_business_rule
  5. Configure the new rule’s references settings:
    1. Name the Rule: Enter a descriptive name that reflects the rule’s purpose.
    2. Select the Target Table: Choose the table the rule will apply to.
    3. Enable the Rule: Check both Active and Advanced.
    4. Set When to Run:
      • Choose After to run the rule once the record changes are saved.
      • Enter the Order value (leave at 100 unless you need a custom sequence).
      • Select the operations (Insert, Update, Delete, Query) that should trigger the rule.
    new_business_rule
  6. Under the Advanced section, insert a JavaScript script that will trigger Blink’s workflow. Click on the Save icon and then Submit. rule_script
    Here’s an example of a rule script that triggers a workflow in Blink:
    Important to Note:
    1. Make sure to copy the full Webhook URL of the workflow you want to trigger in Blink. webhook_url
    2. Replace the https://your-real-webhook-url placeholder in the script with the copied URL.
    3. In the payload variable, add the table columns you want to send when the webhook is triggered, in the following format: col_name: current.getValue('col_name').
    (function executeRule(current, previous) {
    
        var r = new sn_ws.RESTMessageV2();
        r.setEndpoint('https://your-real-webhook-url');
        r.setHttpMethod('POST');
        r.setRequestHeader('Content-Type', 'application/json');
    
        var payload = {
            sys_id: current.getValue('sys_id'),
            sys_created_on: current.getValue('sys_created_on')
        };
    
        r.setRequestBody(JSON.stringify(payload));
    
        try {
            var response = r.execute();
        } catch (ex) {
            gs.error('Webhook call failed: ' + ex.message);
        }
    
    })(current, previous);
    
The following is an example of an event payload received in Blink: event