How to enable push notifications for all users at once, with scripting for mobile

Devika3
Tera Guru

Please let me know how to enable push notifications for all the users at once using scripting.

 

Regards,

Devika.

1 ACCEPTED SOLUTION

Hello Devika,

They are managed in cmn_notif_device table. Try this code. This will register push notification to all active users of sys_user table.

var gr = new GlideRecord("cmn_notif_device");
var user = new GlideRecord("sys_user");
user.addActiveQuery();
user.query();
while(user.next()) {
  gr.initialize();
  gr.name="ServiceNow Classic Mobile Application"; //mention your application name
  gr.type="Push";
  gr.user=user.getValue("sys_id");
  gr.active=true;
  gr.insert();
}

Mark the comment as a correct answer and also helpful if it solves your problem.

View solution in original post

8 REPLIES 8

This is the table used by user to store the user preference by device.

If you  look at type column you can see different options such as email/push/sms etc

So whichever type of notification the user subscribes, then entry is made into this table.

For testing purpose, create a manual entry of 1-2 users and check once. Once working, then you can run a script.

Mark the comment as helpful and correct answer if it answers your question.

Thanks Asif

Hello Devika,

Could you also mark the comment as a correct answer so that the question is moved to the solved list.

Hi Asif ,so where i need to use this script