
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago
This post is for anyone who want to display Catalog Tasks (or any other record) based on information on the user record, like "Employee number" or "Badge number" or "Access Card" stored on the user record.
I know this is nothing new, nor advanced, but I made this for myself or anyone who might find this useful.
Background
We have facility management in the house where employees go to pickup package arrivals. They scan their badge/access card and the USB-RFI-reader enter the card number in ServiceNow search and hit enter.
We now need to find all sc_task that have to be handed out to the "Requested for" user.
The last step in out Flow is to create a task with a notification for the user to pickup their package. Here is how/what we have done to accomplish that.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago - last edited 8 hours ago
Solution
Here's all the steps that I went through to create this.
01. Create Badge number on User record
02. Add the field to User record
03. Give the user a badge number to search for
04. Search for the badge number and see that you get a hit
05. Create the same field on sc_task table
06. Create the Business Rule that insert/copy the value on to the sc_task record for the items that you want. In this case I want it for all sc_task that the user ordered.
07. Script for the Business Rule
Script in Business Rule here:
(function executeRule(current, previous /*null when async*/ ) {
//Add user info to record for search
if (current.request_item && current.request_item.requested_for) {
var userGR = new GlideRecord('sys_user');
if (userGR.get(current.request_item.requested_for)) {
var empNum = userGR.employee_number;
var cardNum = userGR.u_badge_number;
current.u_employee_number = empNum;
current.u_badge_number = cardNum;
}
}
})(current, previous);
08. Search again. No match ( no records created yet. Also need to index result)
09. Add index on sc_task records - Also notice that badge number is shown on sc_task. Go in to form designer and remove the field from the page
10. Add Index on Collection row for sc_task
11. Click generate Index and wait.
12. Order something for Beth. Approve the Request and make sure that a sc_task is created.
13. Search for the Badge number "badge123" in the search bar and notice that you can see the active tasks that is requested for the user with that badge number.
Done.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago - last edited 8 hours ago
Solution
Here's all the steps that I went through to create this.
01. Create Badge number on User record
02. Add the field to User record
03. Give the user a badge number to search for
04. Search for the badge number and see that you get a hit
05. Create the same field on sc_task table
06. Create the Business Rule that insert/copy the value on to the sc_task record for the items that you want. In this case I want it for all sc_task that the user ordered.
07. Script for the Business Rule
Script in Business Rule here:
(function executeRule(current, previous /*null when async*/ ) {
//Add user info to record for search
if (current.request_item && current.request_item.requested_for) {
var userGR = new GlideRecord('sys_user');
if (userGR.get(current.request_item.requested_for)) {
var empNum = userGR.employee_number;
var cardNum = userGR.u_badge_number;
current.u_employee_number = empNum;
current.u_badge_number = cardNum;
}
}
})(current, previous);
08. Search again. No match ( no records created yet. Also need to index result)
09. Add index on sc_task records - Also notice that badge number is shown on sc_task. Go in to form designer and remove the field from the page
10. Add Index on Collection row for sc_task
11. Click generate Index and wait.
12. Order something for Beth. Approve the Request and make sure that a sc_task is created.
13. Search for the Badge number "badge123" in the search bar and notice that you can see the active tasks that is requested for the user with that badge number.
Done.