How to Setup Response Pages in using javascript and ajax for Service-Now

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Please sign in to see details of an important advisory in our Customer Advisories area.

How to Setup Response Pages in using javascript and ajax for Service-Now

L1 Bithead

I'm trying to setup PaloAlto response pages to submit content using "button" to Service-Now.  It seems that in order for content of response page to be 'sent' to Service-Now, javascript and ajax must both be used in the html response page.  My questions are:

 

1) does PaloAlto response pages support ajax?

2) does anyone have an example of submitting content from response page to Service-Now or other ticketing system?

 

Here is code example that I'm working on.

 

<form id = "frm1" action='https://companyname.service-now.com/api/incident' method = "post">
<p>Submit Service-Now ticket for access review.</p><br>
UserName:<br>
<input id= "userID" type="text" name="UserName"><br>
e-Mail:<br>
<input id = "email" type="text" name="e-Mail"><br>
<b>Comment: </b><br>
<textarea id = 'description' cols="50" rows="4" name="Description"></textarea><br>
<input id = "ip" type=hidden name="IP Address" value="<user/>">
<input id = "url" type=hidden name="URL" value="<url/>">
<input id = "pCategory" type=hidden name="PaloAlto Category" value="<category/>">
<input id = "ruleName" type=hidden name="RuleName" value="<rulename/>">
<input id = "snCategory" type=hidden name="SN Category" value="internalADgroup">
<input type=hidden name="Assignment Group" value=&nbsp"internalSNgroup">
<input type=hidden name="SubCategory" value=&nbsp"PaloAlto Gateway">
<input type="reset" value="Reset">
<input type="submit" value"Submit">

 

<script>
function ServiceNowOpenIncident() {
var form = document.querySelector("frm1");
form.addEventListener("submit", function(event) {
console.log("Saving value", form.elements.value.value);
event.preventDefault();
var x = document.getElementById("frm1");
var userID = document.getElementById("userID").value;
var pCategory = document.getElementById("pCategory").value;
var description = document.getElementById("description").value + "<br><strong>" + document.getElementById("ip").name + ":</strong>&nbsp" + document.getElementById("ip").value + ;
var requestBody = "{\"userID\": \"someuser\",\"category\": \"internalSNgroup\",\"subcategory\": \"paloalto_gateway\",\"description\": \"testing form submission to REST Console by ServiceNow\", \"short_description\": \"PaloAlto parked\",\"assignment_group\": \"internalADgroup\"}";
document.getElementById("oms").innerHTML = requestBody;
}
var client=new XMLHttpRequest();
client.open("post","https://companyname.service-now.com/api/incident");

client.setRequestHeader('Accept','application/json');
client.setRequestHeader('Content-Type','application/json');

//Eg. UserName="admin", Password="admin" for this code sample.
client.setRequestHeader('Authorization', 'Basic '+btoa('admin'+':'+'admin'));

client.onreadystatechange = function() {
if (client.readyState === 4 && client.status === 200) {
var json = JSON.parse(client.responseText);
console.log(json.email + ", " + json.password);
};
var data = JSON.stringify(requestBody);
xhr.send(data);
</script>

 

Thanks for reading...

2 REPLIES 2

L7 Applicator

Hi @tlarue

 

Is it already woeking what you're trying to achieve? Because this really is a cool idea.

 

1) there isn't leally a limitation from paloalto with the response pages or with technologies used in them. There is only a size limit. But what you do with these about 24k (I think) is really up to you. If it's possible to do it in a single html file then your good to go. Or if the space isn't enough you could also place content on another webserver and the reponse page then simply fetches this content.

2) I don't know. But your example is a good start 😉

L1 Bithead

Any update on this? Even just the ability to send an email via form on the block page would be powerful. Right now we use Lightspeed Rockets and we are trying to migrate to URL filtering and the ability to submit a blocked URL for review is something Palo Alto is missing compared to its competition.

  • 3205 Views
  • 2 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!