Created
November 23, 2013 21:40
-
-
Save cmcdevitt/7620297 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Test Device | |
//work in progress 11/20/2013 | |
//Dependencies | |
//-- UI Action: Test Device Table: Notification Device [cmn_notif_device], Form Button, Show update (show insert?), Cond:current.isValidRecord() | |
//-- Event: cmn_notif_device.test_device | |
//-- Notification: 'Test My Device' | |
//**** Development Notes ***** | |
//Add Notification to cmn_notif_message | |
//-- Need: Notification Message,User,Device,Send Email,Send SMS | |
//-- D Lookup User sys_id: gs.getUserID(); | |
//-- D Lookup Notification Message from sysevent_email_action | |
//-- D Lookup Device (cmn_notif_device) from current.device | |
//Add Event to Queue: gs.eventQueue | |
//Remove Notification to cmn_notif_message(?) | |
// ***** | |
//gs.log('Device&sys_id: ' + current.name + '&' + current.sys_id,'Chris'); | |
//gs.log('Current User: ' + gs.getUserID(), 'Chris'); | |
var myNotificationName = 'Test My Device'; | |
var myEventName = 'cmn_notif_device.test_device'; | |
var myDevice = current.sys_id; | |
var myUser = gs.getUserID(); | |
var myNotificationMessage = ''; | |
//Find the sys_id of the Notification that we are working with | |
//Expect: a76f041b4889110014c5c69f367de9cd "Test My Device" | |
var myNotificationMsg = new GlideRecord('sysevent_email_action'); | |
myNotificationMsg.addQuery('name', '=', 'Test My Device'); | |
myNotificationMsg.query(); | |
if(myNotificationMsg.next()){ | |
//gs.log('Not&sys_id: ' + myNotificationMsg.name + '&' + myNotificationMsg.sys_id, 'Chris'); | |
myNotificationMessage = myNotificationMsg.sys_id; | |
} | |
//Check to see if our Notificatiion is already set in cmn_notif_message | |
//If Not Then: Insert our Notification into cmn_notif_message | |
//Else skip this step | |
var myNotifis = new GlideRecord('cmn_notif_message'); | |
myNotifis.addQuery('notification', '=', myNotificationMessage); | |
myNotifis.addQuery('user', '=', myUser); | |
myNotifis.query(); | |
if(myNotifis.next()){ | |
//Found it, so no need to add it | |
//gs.log('Found: ' + myNotifis.notification, 'Chris'); | |
}else{ | |
//Did not find it, so we need to add it. | |
myNotifis.initialize(); | |
myNotifis.device = myDevice; | |
myNotifis.user = myUser; | |
myNotifis.notification = myNotificationMessage; | |
myNotifis.send_email = 'true'; | |
myNotifis.send_sms = 'false'; | |
myNotifis.insert(); | |
} | |
gs.eventQueue('cmn_notif_device.test_device',current,current.email_address,gs.getUserName()); | |
gs.addInfoMessage('Message Sent to ' + current.phone_number + '!'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment