- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 12:26 AM
Hi everyone!
I had written an onLoad client script for an incident form (specifically the Security Incident Response form, but I don't think that matters)
-where the script removes some choices in a dropdown field depending on the value of another field.
At first, it works fine, but after one second, ALL the choices come back, undoing the work of the script. I have looked at the Client Script table, UI Actions table, and even at some Data Policies and couldn't find a **bleep** thing to that might affect and override my script for this specific dropdown field.
Does anyone else know where I can look to see if anything else is affecting this field? Or are those three tables the only places?
Script below in case if needed:
function onLoad() {
//var group = g_form.getDisplayBox('assignment_group').value;
var group = g_form.getValue("assignment_group");
if (group == "sysid of group") {
g_form.removeOption('myField', '3');
g_form.removeOption('myField', '13');
//alert("The assignment group is xyzgroup!");
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 12:37 AM
Hi @DeeMendoza,
Could you try the following:
function onLoad() {
setTimeout(function() {
var group = g_form.getValue("assignment_group");
if (group == "sysid of group") {
g_form.removeOption('myField', '3');
g_form.removeOption('myField', '13');
}
}, 1000); // Adjust timing as needed
}
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 01:36 AM
I still do need this fixed, sadly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 01:29 AM
myField is dependent on some other field.
share some more details?
Do you want your script to run for new record and existing record as well?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 01:37 AM
@Ankur Bawiskar wrote:share some more details?
Do you want your script to run for new record and existing record as well?
Ideally this script should only run on existing records. You telling me that myField might be dependent on another field might be a useful clue