
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2016 07:01 AM
Anyone have success setting up a custom 2 button push notification for an Incident? I'd like to have a push notification similar to the approval, but with custom buttons for "Assign to Me" and "Ignore".
Push Notification Message Content.
var json = {
"aps" : {
"sound" : "default"
},
"record" : {
"table" : current.getTableName(),
"sys_id" : current.sys_id,
},
"template" : {
"type": "2 button",
"button1" : {
"title" : "Assign to Me",
"action" : attributes.button_action1,
},
"button2" : {
"title" : "Ignore",
"action" : attributes.button_action2,
}
}
};
json;
button_action1
(function runAction(/*Optional GlideRecord*/ current) {
if (current.getTableName() == "incident" && current.assigned_to == undefined) {
current.comments = "I have assigned this incident to myself";
current.assigned_to = gs.getUser();
current.update();
}
})(current);
button_action2
(function runAction(/*Optional GlideRecord*/ current) {
gs.log(gs.getUser() + " ignored this record: " + current.number);
//writes a message to the system log that the user ignored this incident.
})(current);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2016 09:36 AM
This was the feedback received from Dev task passed up for my HI ticket... two buttons, but they have to be approve and reject and link to the script sys_id that should be taken for the action.
-----------------------
"Wow, I think this documentation is totally inaccurate.
On our apps (iOS and Android), push notifications do not allow custom button titles. The options are "approve"/"reject", and require the aps dictionary to be populated. Here is an example push notification for approvals. The value in approve_foreground and reject_foreground are sys ID's of scripts to run on the server in response to the action."
(function buildJSON(/*GlideRecord*/ current, /*String*/ message, /*Object*/ attributes) {
var json = {};
json = {
"aps" : {
"sound" : "default",
"category" : "approve_reject_foreground"
},
"record" : {
"table" : current.getTableName(),
"sys_id" : current.sys_id
},
"scripts" : {"approve_foreground" : "333ecc6253020200601fa3fc9ec58727",
"reject_foreground" : "632ecc6253020200601fa3fc9ec58708" }
};
return json;
})(current, message, attributes);
-----------------------

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2016 02:21 PM
bootec - Were you able to get this resolved? Or did you open a HI ticket and get a PRB opened? I am attempting to do something similar with an "Accept" or "Reject" action similar to the Notify integration through twilio which prompts for ACC or REJ to accept or reject assignment... it seems that the JSON is ignored and no buttons are rendered. I'm attempting to use the 'ServiceNow Mobile Application' (OOB) as the push app (as opposed to a custom push app).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2016 12:27 PM
Not the response we were looking for from ServiceNow, apparently this is not supported by ServiceNow for the native mobile application... hopefully this follow up saves others some time.
Ethan Hogue (NOW)
I requested assistance for you on this question, but the Development Team has informed me that what you're attempting is a customization that falls out of the scope of what our technical support covers.
I see you have already looked into the community, and it does not appear that anyone has done this successfully.
I have looked at our ServiceNow records, and I have not found any incidents or PRBs associated with creating a custom 2-button push notification.
We can do a couple things from here:
I can submit an Enhancement Request on your behalf requesting this to be included in Out-of-Box functionality. I would think many people would find this feature useful, especially since we've seen multiple community articles inquiring about it. The Mobile Team is always working to make the app a better experience, and they appreciate any feedback they can get.
If this functionality is very important and you need more immediate relief, then we can forward your incident to our Professional Services team. This team exists to help users customize their ServiceNow experience, but bear in mind that this is a chargeable service.
Let me know your thoughts on all of this or if you have any additional questions or concerns. I would like to help as much as I can.
Regards,
Ethan Hogue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2016 09:30 AM
Is it that ServiceNow doesn't support us adding ANY actions to push notifications that use the native apps, or that they don't support custom actions with a 2-button layout?
I've been following the guide in the Wiki about how to add actions and haven't had any luck with it. Push notification example

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2016 09:36 AM
This was the feedback received from Dev task passed up for my HI ticket... two buttons, but they have to be approve and reject and link to the script sys_id that should be taken for the action.
-----------------------
"Wow, I think this documentation is totally inaccurate.
On our apps (iOS and Android), push notifications do not allow custom button titles. The options are "approve"/"reject", and require the aps dictionary to be populated. Here is an example push notification for approvals. The value in approve_foreground and reject_foreground are sys ID's of scripts to run on the server in response to the action."
(function buildJSON(/*GlideRecord*/ current, /*String*/ message, /*Object*/ attributes) {
var json = {};
json = {
"aps" : {
"sound" : "default",
"category" : "approve_reject_foreground"
},
"record" : {
"table" : current.getTableName(),
"sys_id" : current.sys_id
},
"scripts" : {"approve_foreground" : "333ecc6253020200601fa3fc9ec58727",
"reject_foreground" : "632ecc6253020200601fa3fc9ec58708" }
};
return json;
})(current, message, attributes);
-----------------------