ChatGPT said: CI field not changing color after state change script. How to fix it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
I created an onChange client script on the Task table that shows a confirmation message when the State field changes. If the user clicks OK, the Configuration Item (cmdb_ci) field should become mandatory and highlight in yellow for a few seconds. The script runs, but the Configuration Item field color doesn’t change. Can anyone help me understand why the background color isn’t updating or how to make it work properly?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
var answer = confirm("Do you want to make Configuration item mandatory?");
if (answer) {
g_form.setMandatory('cmdb_ci', true);
var ci = g_form.getControl('cmdb_ci');
if (ci) {
ci.style.backgroundColor = "yellow"; // highlight
setTimeout(function() {
ci.style.backgroundColor = ""; // remove color after 5 sec
}, 5000);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi @ShrutiS49708912,
Please don't believe chatGPT, it is hallucinating a lot... not only about this but in general, mankind is doomed trusting it too much :(((
I don't think that the field could be highlighted for a few seconds only, that's not possible and if so that would be super complicated...
Instead you can add showFieldMsg() via catalog client script that can be yellow (warning). What do you reckon?
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
can you give me the whole code , what you are telling??
