Why is my notification not triggering when a Business Owner becomes inactive

Community Alums
Not applicable

Hi Everyone,

 

I have created a notification on the Business Service table to trigger whenever any of the Business Owners (e.g., 'Owned by' or 'Managed by') become inactive. Here’s what I added the conditions:

Condition 1: Run when "Updated"

Condition 2:'Owned by.Active' is false OR 'Managed by.Active' is false etc..

However, the notification isn’t firing when a business owner becomes inactive. The fields 'Owned by' and 'Managed by' reference users, so I expected this to work when their status changes to inactive. Am I missing something in how the condition or trigger works for reference fields? How can I ensure this notification fires correctly?

 

Regards,

Sowmya Maradana

2 ACCEPTED SOLUTIONS

Hemanth M1
Giga Sage
Giga Sage

Hi @Community Alums ,

 

Yes, Your notification on the Business Service table but update happens on the user table so it wouldn't trigger.

 

You may have to create a Business Rule or a Flow designer on the user table when user becmes inactive check if inactive user is owner of the any business service if yes call the notification

 

I would recommed to use flow designer for its low code capibility.

 

Hope this helps!!!

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

aryanjain25
Giga Guru

Hi @Community Alums ,

Here’s how you can create a Business Rule on the sys_user table that triggers a notification when a user becomes inactive, and they are associated with any Business Service record.

 

Steps to create the Business Rule:

 

1. Navigate to Business Rules:

    • Go to System DefinitionBusiness Rules in ServiceNow.

2. Create a new Business Rule:

   •Click on New to create a new Business Rule.

3. Set the Basic Information:

   • Name: Notify Business Service Owners Inactive

   • Table: sys_user

   •When: After

   •Update: Check the box for Update (since we want to catch when a user is updated).

4. Filter Condition:

   •Set the condition to check when the user becomes inactive:

     Active is false

5. Script: Use this script to check if the user is linked as ‘Owned by’ or ‘Managed by’ in any Business Service record.

 

 

(function executeRule(current, previous) {

    // Check if the user status has changed to inactive
    if (previous.active && !current.active) {
        
        // Query the Business Service table for records where the user is 'Owned by' or 'Managed by'
        var businessServiceGR = new GlideRecord('cmdb_ci_service');
        businessServiceGR.addQuery('owned_by', current.sys_id);
        businessServiceGR.addOrCondition('managed_by', current.sys_id);
        businessServiceGR.query();
        
        while (businessServiceGR.next()) {
            // Trigger a notification for each Business Service record the user is associated with
            gs.eventQueue('business_service.owner_inactive', businessServiceGR, current.sys_id, null);
        }
    }

})(current, previous);

 

 

 

Screenshot 2024-09-28 at 3.02.30 PM.png

 

Steps to Create a Notification:

 

1. Navigate to Notifications:

    • Go to System NotificationNotifications.

2. Create a new Notification:

    • Table: Business Service [cmdb_ci_service]

    •Condition: Add any additional conditions if required, but you can leave it blank as the event will only trigger for                             the inactive owners.

3. Who will receive:

    •Specify who should receive the notification (e.g., Business Owners, System Admin, etc.).

4. Message:

    •You can configure the email subject and body based on your needs.

 

I would appreciate if you can mark this response as correct or helpful if it helped you with your question.

 

Thanks,

Aryan Jain

View solution in original post

3 REPLIES 3

Hemanth M1
Giga Sage
Giga Sage

Hi @Community Alums ,

 

Yes, Your notification on the Business Service table but update happens on the user table so it wouldn't trigger.

 

You may have to create a Business Rule or a Flow designer on the user table when user becmes inactive check if inactive user is owner of the any business service if yes call the notification

 

I would recommed to use flow designer for its low code capibility.

 

Hope this helps!!!

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

aryanjain25
Giga Guru

Hi @Community Alums ,

Here’s how you can create a Business Rule on the sys_user table that triggers a notification when a user becomes inactive, and they are associated with any Business Service record.

 

Steps to create the Business Rule:

 

1. Navigate to Business Rules:

    • Go to System DefinitionBusiness Rules in ServiceNow.

2. Create a new Business Rule:

   •Click on New to create a new Business Rule.

3. Set the Basic Information:

   • Name: Notify Business Service Owners Inactive

   • Table: sys_user

   •When: After

   •Update: Check the box for Update (since we want to catch when a user is updated).

4. Filter Condition:

   •Set the condition to check when the user becomes inactive:

     Active is false

5. Script: Use this script to check if the user is linked as ‘Owned by’ or ‘Managed by’ in any Business Service record.

 

 

(function executeRule(current, previous) {

    // Check if the user status has changed to inactive
    if (previous.active && !current.active) {
        
        // Query the Business Service table for records where the user is 'Owned by' or 'Managed by'
        var businessServiceGR = new GlideRecord('cmdb_ci_service');
        businessServiceGR.addQuery('owned_by', current.sys_id);
        businessServiceGR.addOrCondition('managed_by', current.sys_id);
        businessServiceGR.query();
        
        while (businessServiceGR.next()) {
            // Trigger a notification for each Business Service record the user is associated with
            gs.eventQueue('business_service.owner_inactive', businessServiceGR, current.sys_id, null);
        }
    }

})(current, previous);

 

 

 

Screenshot 2024-09-28 at 3.02.30 PM.png

 

Steps to Create a Notification:

 

1. Navigate to Notifications:

    • Go to System NotificationNotifications.

2. Create a new Notification:

    • Table: Business Service [cmdb_ci_service]

    •Condition: Add any additional conditions if required, but you can leave it blank as the event will only trigger for                             the inactive owners.

3. Who will receive:

    •Specify who should receive the notification (e.g., Business Owners, System Admin, etc.).

4. Message:

    •You can configure the email subject and body based on your needs.

 

I would appreciate if you can mark this response as correct or helpful if it helped you with your question.

 

Thanks,

Aryan Jain

Could this be use to flag non IT Owners?