How can I hide a user from the "assign to" choices ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2024 01:39 AM
Hi everyone, I have been asked to remove a user from the "assign to" choices, in this case the users that open the records, shouldnt be abble to assign it to this certain user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2024 01:23 AM
Sure, you can achieve this by creating a Data Lookup rule. Here are the steps:
1. Navigate to System Definition > Data Lookup Definitions.
2. Click on New to create a new Data Lookup Definition.
3. Fill in the fields:
- Name: Give a name to your Data Lookup Definition.
- Source table: Select the table where you want to apply this rule (for example, Incident [incident]).
- Match fields: Add a new row and select "Assigned to" in the Field column.
- Set fields: Add a new row and select "Assigned to" in the Field column.
4. In the Advanced section, add a script to exclude the specific user from the "Assigned to" field. Here is a sample script:
javascript
(function excludeUser() {
var userSysId = 'sys_id_of_the_user'; // Replace with the sys_id of the user you want to exclude
var assignedTo = current.assigned_to;
if (assignedTo == userSysId) {
current.assigned_to = '';
}
})();
5. Click on Submit to save the Data Lookup Definition.
Please note that you need to replace 'sys_id_of_the_user' with the actual sys_id of the user you want to exclude. You can find the sys_id of a user in the User [sys_user] table.
This script will remove the specific user from the "Assigned to" field whenever a record is created or updated. If you want to apply this rule only when a record is created, you can add a condition to check if the record is new:
javascript
if (current.isNewRecord() && assignedTo == userSysId) {
current.assigned_to = '';
}
Remember to test this in a sub-production instance before applying it to your production instance.
nowKB.com
If you want to know any information about Service Now . Visit to https://nowkb.com/home