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

Hi Asif,

 

We have enabled the notifications. The requirement is to enable these notifications for all the users at once using scripting.

Regards,

Devika.

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.

Hi Asif,

 

Is it okay to  insert new records into this table manually? Does it affect any other things or data?

Please let me know whether any another dependencies are there on this table?

 

Regards,

Devika.