Last active
October 21, 2019 22:08
-
-
Save voipnorm/cb6f52364936eec8e87c6fcceb2ad0e2 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
function getServiceNowIncidentIdFromURL(url){ | |
return xapi.command('HttpClient Get', { 'Header': [CONTENT_TYPE, SERVICENOW_AUTHTOKEN] , 'Url':url, 'AllowInsecureHTTPS': 'True'}); | |
} | |
function raiseTicket(message){ | |
console.log('Message raiseTicket: ' + message); | |
var messagecontent = { description: systemInfo.softwareVersion , short_description: message }; | |
xapi.command('HttpClient Post', { 'Header': [CONTENT_TYPE, SERVICENOW_AUTHTOKEN] , 'Url':MONITORING_URL, 'AllowInsecureHTTPS': 'True'} | |
, JSON.stringify(messagecontent)).then( | |
(result) => { | |
const serviceNowIncidentLocation = result.Headers.find(x => x.Key === 'Location'); | |
var serviceNowIncidentURL = serviceNowIncidentLocation.Value; | |
var serviceNowIncidentTicket; | |
getServiceNowIncidentIdFromURL(serviceNowIncidentURL).then( | |
(result) => { | |
var body = result.Body; | |
console.log('Got this from getServiceNowIncidentIdFromURL: ' + JSON.stringify(result)); | |
serviceNowIncidentTicket = JSON.parse(body).result.number; | |
xapi.command("UserInterface Message Alert Display", { | |
Title: 'ServiceNow receipt' | |
, Text: 'Your ticket id is ' + serviceNowIncidentTicket + '. Thanks for you feedback! Have an awesome day!' | |
, Duration: 10 | |
}).catch((error) => { console.error(error); }) | |
}); | |
console.log('Got this from raiseTicket: ' + JSON.stringify(result)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment