logo

NJP

Remove watch list user using email link

Import · Jun 08, 2020 · article

I have seen many threads on community where user wants to add some functionality over email to do some delete or update operation over the record using email notification link.

So i have a one solution hope it will help other.

Scenario: Email link to remove logged in user from watch list.

Solution:

  1. Create Template ( Email >> Templates ).
  2. Update mailto template on notification.
  3. Update existing reply type inbound action using some server side scripts

Screenshot for reference:

Templates:

image

Notification: Here i have called the mailto into the notification

image

Inbound Action: For testing i have just updated ootb reply type inbound action.

image

gs.include('validators');

if (current.getTableName() == "incident") {

    var gr = current;

    if (email.subject.toLowerCase().indexOf("please reopen") >= 0)
        gr = new Incident().reopen(gr, email) || gr;

    gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
    if (gs.hasRole("itil")) {
        if (email.body.assign != undefined)
            gr.assigned_to = email.body.assign;

        if (email.body.priority != undefined && isNumeric(email.body.priority))
            gr.priority = email.body.priority;

        if(email.subject.toLowerCase().indexOf("watchlist") >= 0){
            var aUtil = new ArrayUtil();
            var id = [gs.getUserID()];
            var wlist = gr.watch_list.toString().split(',');
            gr.watch_list=aUtil.diff(wlist,id).join();
        }
    }

    gr.update();
}

Result: You will see the link over the email notification which will allow you to update the action over the record.

image

Just want to add another point here, this scenario has been tested if you want to perform any other operation so just make some changes in inbound action and fulfill your requirement. Hope it will help you.

Thanks,

Harshvardhan

View original source

https://www.servicenow.com/community/in-other-news/remove-watch-list-user-using-email-link/ba-p/2270056