- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2025 10:33 AM
Hi guys, what's up?
I'm working on the customer_account table and I'd like to know how I can:
- Create a field to indicate whether the record is active or not (for example, an "Active?" field);
- Configure so that deactivated records don't appear in lists automatically.
Could someone advise me on how to do this? Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2025 11:03 AM
Problem Name: Add Active Field and Hide Inactive Records
General Solution Proposal:
To manage active and inactive records in the customer_account table, add a Boolean field named Active. Then, implement a "Before Query" Business Rule to automatically filter out inactive records from list views, ensuring only active records are displayed by default.
Detailed Step-by-Step Solution:
Add the 'Active' Field:
Navigate to System Definition > Tables.
Search for and open the customer_account table.
In the Columns section, click New.
Set the following:
Column label: Active
Column name: active
Type: Boolean
Default value: true
Click Submit to save the new field.
Create a 'Before Query' Business Rule:
Go to System Definition > Business Rules.
Click New to create a new Business Rule.
Configure the Business Rule:
Name: Filter Active Customer Accounts
Table: customer_account
Advanced: Checked
When: Before
Insert: Unchecked
Update: Unchecked
Delete: Unchecked
Query: Checked
In the Script section, enter:
// Filter to show only active records if (!gs.hasRole('admin')) { current.addQuery('active', true); }
Click Submit to save the Business Rule.
Note: This script ensures that only users without the 'admin' role see active records by default. Admins can view all records.
Example Use Case:
A ServiceNow administrator wants to prevent end-users from seeing inactive customer accounts in list views. By adding an 'Active' field and implementing a Business Rule, inactive records are hidden from standard users, maintaining data relevance and cleanliness.
Prepare for discussion on the solution:
Why use a Business Rule instead of ACLs?
Business Rules are suitable for modifying query behavior before data retrieval, ensuring inactive records are excluded from list views without affecting form access controls.Can this approach be extended to reference fields?
Yes, by adding a reference qualifier to reference fields pointing to customer_account, you can ensure only active records are selectable.What if different roles require different visibility?
Modify the Business Rule script to include role checks, displaying records based on user roles.
Sources:
What is the best way to hide a record? - ServiceNow Community
Discusses adding an 'Active' field and using reference qualifiers to filter records.Unable to hide records from list view - ServiceNow Community
Suggests using a 'Before Query' Business Rule to filter records in list views.Hide Column from List View - ServiceNow Community
Explains using ACLs to control visibility of fields in list views.
Final Version:
By adding an 'Active' Boolean field to the customer_account table and implementing a 'Before Query' Business Rule, you can effectively manage the visibility of active and inactive records in list views. This approach ensures that users see only relevant, active records by default, enhancing data management and user experience.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2025 10:50 AM - edited ‎05-06-2025 10:51 AM
To accomplish your first ask, you need to create a field titled "Active" of type "True/False" on your table. To find where to do this, go to your list view, click on the three dots next to a column header, and choose Configure > Table.
You'll then open the Columns related list and click New to create your field.
Note: I am not familiar with the Customer Account table. It's possible there is already an Active field. To find this out, instead of creating a new column, first search the columns for the field "Active".
To accomplish your second ask, you'll need to update the Module that links to your table. Go to System Definition > Modules and locate the module that users use to go to your list of records. In the Link Type section, add the condition for Active is true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2025 10:50 AM - edited ‎05-06-2025 05:45 PM
As admin user, goto the custer_account table and add a new column as below
Next, create a business rule as shown below
You could always just filter the list 'u_active=true'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2025 11:03 AM
Problem Name: Add Active Field and Hide Inactive Records
General Solution Proposal:
To manage active and inactive records in the customer_account table, add a Boolean field named Active. Then, implement a "Before Query" Business Rule to automatically filter out inactive records from list views, ensuring only active records are displayed by default.
Detailed Step-by-Step Solution:
Add the 'Active' Field:
Navigate to System Definition > Tables.
Search for and open the customer_account table.
In the Columns section, click New.
Set the following:
Column label: Active
Column name: active
Type: Boolean
Default value: true
Click Submit to save the new field.
Create a 'Before Query' Business Rule:
Go to System Definition > Business Rules.
Click New to create a new Business Rule.
Configure the Business Rule:
Name: Filter Active Customer Accounts
Table: customer_account
Advanced: Checked
When: Before
Insert: Unchecked
Update: Unchecked
Delete: Unchecked
Query: Checked
In the Script section, enter:
// Filter to show only active records if (!gs.hasRole('admin')) { current.addQuery('active', true); }
Click Submit to save the Business Rule.
Note: This script ensures that only users without the 'admin' role see active records by default. Admins can view all records.
Example Use Case:
A ServiceNow administrator wants to prevent end-users from seeing inactive customer accounts in list views. By adding an 'Active' field and implementing a Business Rule, inactive records are hidden from standard users, maintaining data relevance and cleanliness.
Prepare for discussion on the solution:
Why use a Business Rule instead of ACLs?
Business Rules are suitable for modifying query behavior before data retrieval, ensuring inactive records are excluded from list views without affecting form access controls.Can this approach be extended to reference fields?
Yes, by adding a reference qualifier to reference fields pointing to customer_account, you can ensure only active records are selectable.What if different roles require different visibility?
Modify the Business Rule script to include role checks, displaying records based on user roles.
Sources:
What is the best way to hide a record? - ServiceNow Community
Discusses adding an 'Active' field and using reference qualifiers to filter records.Unable to hide records from list view - ServiceNow Community
Suggests using a 'Before Query' Business Rule to filter records in list views.Hide Column from List View - ServiceNow Community
Explains using ACLs to control visibility of fields in list views.
Final Version:
By adding an 'Active' Boolean field to the customer_account table and implementing a 'Before Query' Business Rule, you can effectively manage the visibility of active and inactive records in list views. This approach ensures that users see only relevant, active records by default, enhancing data management and user experience.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2025 02:21 PM
Problem Name: Managing Active Status in customer_account Table 🟢🔴
General Solution Proposal:
To manage active and inactive records in the customer_account table, add a Boolean field named Active. Then, implement a "Before Query" Business Rule to automatically filter out inactive records from list views, ensuring only active records are displayed by default.
Detailed Step-by-Step Solution:
Add the 'Active' Field:
Navigate to System Definition > Tables.
Search for and open the customer_account table.
In the Columns section, click New.
Set the following:
Column label: Active
Column name: active
Type: Boolean
Default value: true
Click Submit to save the new field.
Create a 'Before Query' Business Rule:
Go to System Definition > Business Rules.
Click New to create a new Business Rule.
Configure the Business Rule:
Name: Filter Active Customer Accounts
Table: customer_account
Advanced: Checked
When: Before
Insert: Unchecked
Update: Unchecked
Delete: Unchecked
Query: Checked
In the Script section, enter:
// Filter to show only active records if (!gs.hasRole('admin')) { current.addQuery('active', true); }
Click Submit to save the Business Rule.
Note: This script ensures that only users without the 'admin' role see active records by default. Admins can view all records.
Example Use Case:
A ServiceNow administrator wants to prevent end-users from seeing inactive customer accounts in list views. By adding an 'Active' field and implementing a Business Rule, inactive records are hidden from standard users, maintaining data relevance and cleanliness.
Prepare for Discussion on the Solution:
Why use a Business Rule instead of ACLs?
Business Rules are suitable for modifying query behavior before data retrieval, ensuring inactive records are excluded from list views without affecting form access controls.Can this approach be extended to reference fields?
Yes, by adding a reference qualifier to reference fields pointing to customer_account, you can ensure only active records are selectable.What if different roles require different visibility?
Modify the Business Rule script to include role checks, displaying records based on user roles.
Sources:
Dow to add 'active' field on a table - ServiceNow Community
Link
Discusses adding an 'Active' field and using a Business Rule to filter records in list views.What is the best way to hide a record? - ServiceNow Community
Link
Suggests adding an 'Active' field and using reference qualifiers to filter records.Hide Column from List View - ServiceNow Community
Link
Explains using ACLs to control visibility of fields in list views.
If you need assistance implementing this solution or have further questions, feel free to ask! 😊