ServiceNow Agent App - Add to Watch List Function

Jaret Vik
Tera Expert

Is there a way to add an action item or function to a record screen that allows the adding of users to the Watch List? Do I just make a sys_user reference field input or should it be done another way?

1 ACCEPTED SOLUTION

Jaret Vik
Tera Expert

I don't know why, but the original way I tried to do it worked like a charm after I was explaining it to someone else. Go figure!

The normal 'Update' type Action item works just fine for the Watch list. 

JaretVik_1-1774527332162.png

JaretVik_2-1774527410357.png

 

View solution in original post

6 REPLIES 6

ayushraj7012933
Mega Guru

 

Hi   @Jaret Vik 

Yes, you can add an “Add to Watch List” function in the Agent App, and the correct approach is to use the OOTB Watch List (Glide List) field, not a single reference field.

Below are the step-by-step instructions 

Best Approach: Use Watch List + Action

🔹 Step 1: Verify Watch List Field

  1. Go to your table (e.g., Incident or custom table)

  2. Check if field watch_list exists

  3. If not:

    • Create a new field:

      • Type: Glide List

      • Reference: sys_user

Step 2: Add Field to Agent Form

  1. Go to:

    • Workspace Experience → Form Layout (or Form Designer)

  2. Add Watch List field to the form

  3. Save and reload

Now users can directly add multiple users

Step 3: Create “Add to Watch List” Action

  1. Go to System Definition → UI Actions

  2. Click New

Configure:

  • Table: your table (e.g., Incident)

  • Name: Add to Watch List

  • Show on: Form / Workspace

  • Action type: Form button

Step 4: Add Script to Append Users

var users = 'sys_id1,sys_id2'; // selected users
current.watch_list = current.watch_list
? current.watch_list + ',' + users
: users;
current.update();
action.setRedirectURL(current);

I need to add this function on the Mobile Agent App, not a form or workspace. I posted this question in the 'Mobile Apps & Platform' section. 

 

Hi   @Jaret Vik ,

Thanks for clarifying — since this is for the Mobile Agent App, the approach is different from Workspace/UI 

You should not create a simple sys_user reference field. The Watch List is a Glide List (multi-user) field, so it needs to be handled accordingly in Mobile.

Recommended Approach (Mobile Agent App)

Step 1: Ensure Watch List Field Exists

  • Field: watch_list

  • Type: Glide List

  • Reference: sys_user

Step 2: Add Watch List to Mobile Screen

  1. Go to Mobile Studio → Agent App

  2. Open the Record Screen

  3. Add field:

    • Watch List

  4. Save & Publish

This allows direct viewing/editing if needed

Step 3: Create Action Item

  1. Go to Mobile Studio → Action Items

  2. Create new:

    • Name: Add to Watch List

    • Table: your table

    • Action Type: Script Action

Step 4: Add Input for Users

  • Add input:

    • Type: Reference → sys_user

  • (If multi-select not available, you may need to handle multiple selections via custom logic)

Step 5: Script to Update Watch List

(function execute(inputs, outputs) {
vr rec = new GlideRecord(inputs.table);
if (rec.get(inputs.sys_id)) {
var existing = rec.watch_list ? rec.watch_list.toString() : '';
var newUser = inputs.user; // selected user sys_id
rec.watch_list = existing
? existing + ',' + newUser
: newUser;
rec.update();
}
})(inputs, outputs);
 

Step 6: Attach Action to Screen

  • Add this Action Item to your Record Screen

  • Place it in header/footer

Tanushree Maiti
Kilo Patron

Hi @Jaret Vik ,

You can create a UI Action button. This button can either instantly add the current user or logic (script) you can add for a user selection.

 

Sample:

  1. Navigate to System Definition > UI Actions.
  2. Click New.
  3. Configure the UI Action:
    • Name: Add Me to Watch List
    • Table:  incident (or your desired table)
    • Action name: add_me_to_watchlist
    • Form button: Checked
    • Client: false
  4. Script:
    function addToWatchList() {
    var
    userSysId = gs.getUserID(); var watchList = current.watch_list; if (watchList.indexOf(userSysId) == -1) { if (watchList == "") { current.watch_list = userSysId; } else { current.watch_list += "," + userSysId; } current.update(); gs.addInfoMessage("You have been added to the Watch List."); } else { gs.addInfoMessage("You are already in the Watch List."); }
    }
Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: