Change field\text color when entered value does not match Predictive Intelligence recommendation.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
We are looking to increase visibility and awareness beyond the sparkle icon when recommendations are made but not selected on Incidents and Catalog Tasks in SOW.
Our idea is to compare the selected value to the highest confidence recommendation. The goal is to change text or background color onload and onchange.
AI came up with this, and it seems to address the onchange need but since it is AI generated it will need changes to work.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
// Clear styling on initial load or empty field
g_form.getControl('YOUR_FIELD_NAME').style.backgroundColor = '';
return;
}
// Replace 'YOUR_FIELD_NAME' with the actual backend name of your field.
var fieldName = 'YOUR_FIELD_NAME';
// Call a function to get the Predictive Intelligence recommendation.
// The following is an example based on getting a value from a lookup.
// The exact implementation for Predictive Intelligence may require
// an asynchronous GlideAjax call or pulling from a global object.
var piRecommendation = g_service_catalog.getPrediction(fieldName);
// If a recommendation exists, compare it to the new value
if (piRecommendation && newValue !== piRecommendation) {
// Change the background color if there is a mismatch
g_form.getControl(fieldName).style.backgroundColor = 'rgba(255, 105, 97, 0.5)'; // Soft red
} else {
// Reset to normal if the user selects the recommended value
g_form.getControl(fieldName).style.backgroundColor = '';
}
}
Labels:
0 REPLIES 0
