i plan to create a SP widget with Chatgpt integrate summaries the ticket and provide recommendation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2024 07:15 AM
i plan to create a SP widget with Chatgpt integrate where the user enters the serial number of the laptop and it will pull out all the ticket and provide summaries the ticket and provide recommendation
<!-- Widget HTML -->
<div class="incident-widget">
<h2>ChatGPT Incident Summary</h2>
<div class="input-container">
<label for="assetInput">Enter Impacted Asset:</label>
<input type="text" id="assetInput" placeholder="Asset Name">
<button onclick="fetchIncidentData()">Fetch Data</button>
</div>
<div id="summaryContainer"></div>
</div>
<!-- ChatGPT iframe -->
<iframe id="chatGPTFrame" src="https://your-chatgpt-url.com" width="100%" height="500px"></iframe>
CSS
/* Widget Styles */
.incident-widget {
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
margin-bottom: 20px;
}
.input-container {
margin-top: 10px;
}
server script
/ IncidentWidgetScriptInclude
var IncidentWidgetScriptInclude = Class.create();
IncidentWidgetScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getIncidentData: function() {
var assetName = this.getParameter('sysparm_asset');
var incidentTable = new GlideRecord('incident');
incidentTable.addQuery('asset', assetName);
incidentTable.query();
var result = [];
while (incidentTable.next()) {
var summary = incidentTable.getValue('short_description');
var recommendation = incidentTable.getValue('recommendation_field');
result.push({
summary: summary,
recommendation: recommendation
});
}
return JSON.stringify(result);
},
type: 'IncidentWidgetScriptInclude'
});
Client :
/// Widget Client Script
function fetchIncidentData() {
var assetName = document.getElementById('assetInput').value;
// Use GlideAjax to call the server script
var ga = new GlideAjax('IncidentWidgetScriptInclude');
ga.addParam('sysparm_name', 'getIncidentData');
ga.addParam('sysparm_asset', assetName);
ga.getXMLAnswer(function(response) {
var data = JSON.parse(response);
// Process data and update the summary container
var summaryContainer = document.getElementById('summaryContainer');
summaryContainer.innerHTML = '<h3>Incident Summary:</h3>';
data.forEach(incident => {
var summary = incident.summary;
var recommendation = incident.recommendation;
// Display incident summary
summaryContainer.innerHTML += `<p><strong>Summary:</strong> ${summary}</p>`;
summaryContainer.innerHTML += `<p><strong>Recommendation:</strong> ${recommendation}</p>`;
});
});
}
var assetName = 'your_impacted_asset_name';
var incidentTable = new GlideRecord('incident');
incidentTable.addQuery('asset', assetName);
incidentTable.query();
while (incidentTable.next()) {
// Process each incident record
var summary = incidentTable.getValue('short_description');
var recommendation = incidentTable.getValue('your_recommendation_field');
// Add logic to compile summary and recommendation
}
// Display incident summary
summaryContainer.innerHTML += `<p><strong>Summary:</strong> ${summary}</p>`;
summaryContainer.innerHTML += `<p><strong>Recommendation:</strong> ${recommendation}</p>`;
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2024 09:02 PM
what is your question?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2024 02:06 AM
@DanielCordick first time scripting does it make sense ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2024 09:13 AM - edited 01-28-2024 09:39 AM
May I suggest taking the chucks learn JavaScript on the now platform
https://youtu.be/nK1aPdGyGak?si=oRUQjdiW0wPKji7e
If this is also your first time scripting, maybe take some Now learning courses on scripting, maybe service portal fundamentals
There are plenty of resource on nowLearning that would help you tremendously
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2024 04:40 PM
@DanielCordick point noted .