- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Community,
We have new integration requirement, need to fetch the ADO PBI data to ServiceNow
created script include and Ui page, but script include code not executing. so any suggestion?
UI Page code
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I used your suggestion and looks like it does need to be adjusted in ShrinivasprN code. I tweaked my UI Page and script include to try and replicate what was provided and was able to get:
Adjusted UI Page:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
ShrinivasprN,
The first thing I would check is if the script include is client callable. I copied your code into dev. I put in a log entry in the script include and I saw my entry in the log even though I do not have the REST call setup. When I cleared the client callable checkbox on the script include, I no longer had the log statement. Second, if the script include is being triggered I would verify the REST call is working.
Hope that may help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Can you try this version of your UI Page (attached). Also...have you confirmed your REST call is working by trying it independent of the UI Page calling it?
<html>
<head>
<script>
function fetchIncident() {
var pbiId = document.getElementById("pbi_input").value;
if (!pbiId) {
alert("Please enter a PBI ID.");
return;
}
var ga = new GlideAjax('ADOIncidentFetcher');
ga.addParam('sysparm_name', 'fetchPBI');
ga.addParam('sysparm_pbi_id', pbiId);
ga.getXMLAnswer(function(response) {
console.log("Response from server:", response);
var resultDiv = document.getElementById("result");
try {
var data = JSON.parse(response);
if (data.error) {
resultDiv.innerHTML = `<p style="color:red;">Error: ${data.error}</p>`;
} else {
resultDiv.innerHTML = `
<table border="1" style="border-collapse: collapse;">
<tr><th>ID</th><td>${data.id}</td></tr>
<tr><th>Title</th><td>${data.title}</td></tr>
<tr><th>State</th><td>${data.state}</td></tr>
<tr><th>Work Item Type</th><td>${data.workItemType}</td></tr>
</table>
`;
}
} catch (e) {
resultDiv.innerHTML = `<p style="color:red;">Invalid JSON response: ${e.message}</p>`;
}
});
}
</script>
</head>
<body>
<h2>Get ADO PBI / Incident Details</h2>
<label for="pbi_input">Enter PBI ID: </label>
<input type="text" id="pbi_input" />
<button onclick="fetchIncident()">Fetch</button>
<hr/>
<div id="result"></div>
</body>
</html>