- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2024 09:53 PM
on "sn_customerservice_case" what I need is to designed a display a message on a ServiceNow form, alerting users to check certain fields that have been predicted by AI for accuracy.
OOB script include "CSMAIDisplayAjax" is there already. Can anyone help me out
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2024 07:02 AM
Hello,
Its OOB script we can use :-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2024 11:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2024 11:49 PM
One More Easy way is below :-->
Create a Client Script: To display a message on the form, you can use a Client Script to execute the logic and display the message. The Client Script will call the Script Include method to fetch any prediction results and then use those results to display a message.
Here’s an example of a Client Script that could be used:
// Client Script: onLoad
(function executeRule(current, previous /*null when async*/) {
// Call the Script Include function to get predictions
var gr = new GlideAjax('CSMAIDisplayAjax');
gr.addParam('sys_id', current.sys_id);
gr.getXMLAnswer(function(response) {
var result = response.responseXML.documentElement.getAttribute("answer");
if (result) {
// Display message based on the result
g_form.addInfoMessage('AI has predicted some fields for accuracy check: ' + result);
}
});
})(current, previous);
- This script sends the
sys_idof the current record to the Script Include and retrieves a response. - It then displays an info message on the form with the result.
var CSMAIDisplayAjax = Class.create(); CSMAIDisplayAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, { getPredictedFields: function() { var sys_id = this.getParameter('sys_id'); // Example logic to retrieve predictions var message = this.getPredictions(sys_id); // Implement this function as needed return message; }, getPredictions: function(sys_id) { // Add logic to fetch and return predictions based on sys_id // Example: var predictions = 'Field1, Field2'; // Placeholder for actual predictions return predictions; } });
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2025 01:19 PM
can you show a screenshot of it in action ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2024 11:49 PM
One More Easy way is below :-->
Create a Client Script: To display a message on the form, you can use a Client Script to execute the logic and display the message. The Client Script will call the Script Include method to fetch any prediction results and then use those results to display a message.
Here’s an example of a Client Script that could be used:
// Client Script: onLoad
(function executeRule(current, previous /*null when async*/) {
// Call the Script Include function to get predictions
var gr = new GlideAjax('CSMAIDisplayAjax');
gr.addParam('sys_id', current.sys_id);
gr.getXMLAnswer(function(response) {
var result = response.responseXML.documentElement.getAttribute("answer");
if (result) {
// Display message based on the result
g_form.addInfoMessage('AI has predicted some fields for accuracy check: ' + result);
}
});
})(current, previous);
- This script sends the
sys_idof the current record to the Script Include and retrieves a response. - It then displays an info message on the form with the result.
var CSMAIDisplayAjax = Class.create(); CSMAIDisplayAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, { getPredictedFields: function() { var sys_id = this.getParameter('sys_id'); // Example logic to retrieve predictions var message = this.getPredictions(sys_id); // Implement this function as needed return message; }, getPredictions: function(sys_id) { // Add logic to fetch and return predictions based on sys_id // Example: var predictions = 'Field1, Field2'; // Placeholder for actual predictions return predictions; } });