Automatically add users and distribution list to watchlist using Workflow.

Jagadish10
Mega Expert

Hi Everyone,

I want to Automatically add users and distribution list to watch list using Workflow.

In the workflow I'm using the run script and below is the script I got from Add multiple users to Watch List via Workflow

Script.JPG

However, this script is not adding the users and distribution lists. I have made the required changes to the user sys_id and included required email address but still nothing working.

Any help from you guys would be great.

Thanks

Jagadish

1 ACCEPTED SOLUTION

Venkat122
Kilo Guru

Hi Jagadish,



Please try below



var usersandemails = '';


usersandemails = 'a@example.com,b@test.com';



current.watch_list = usersandemails;


View solution in original post

3 REPLIES 3

Venkat122
Kilo Guru

Hi Jagadish,



Please try below



var usersandemails = '';


usersandemails = 'a@example.com,b@test.com';



current.watch_list = usersandemails;


Hi Venkat,

Thanks for the script. It's working perfect now.

Regards

Jagadish

Renu3
Giga Contributor

Hello Venkat,

I tried to follow your guidance and created the below business rule to send an notification to a email Distribution list.The notification is being sent to the groups,caller,onbelahf person but not the DL in watchlist.

Could you please check the code and help me out.

the IT_Ops_Communication@anc.com is a DL group and it is very active in outlook.

(function executeRule(current, previous /*null when async*/ ) {

    var gr = new GlideRecord("incident");
    gr.addQuery("caller_id", current.caller_id);
    gr.addQuery("business_service", current.business_service);
    gr.query();
    if (gr.next()) {

        var usersandemails = '';
        usersandemails = 'IT_Ops_Communication@anc.com';
        current.watch_list = usersandemails;
        var currentList = current.watch_list;

        if (currentList.indexOf(user_name) !== undefined) {
            gs.addInfoMessage("User already present in the WatchList hence not added");

        } else

        if ((current.business_service.getDisplayValue() == "MES" || current.business_service.getDisplayValue() == "Mes ALE" || current.business_service.getDisplayValue() == "MES Global" || current.business_service.getDisplayValue() == "AES-EI ALE" || current.business_service.getDisplayValue() == "AES/EI Global")) {


            gs.addInfoMessage("Adding users to the watchlist");
            //for (var i = 0; i < user_name.length; i++) {

            currentList += usersandemails + ',' + current.u_on_behalf_of;
            //}


        } else {
            gs.addInfoMessage("check the services please");


        }
    }

})(current, previous);