- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-17-2025 10:36 AM
Team
How would you do the following?
1.Open cmdb_ci_server.list
2.Click New
3. Make Field Discovery Source Field Show = Manual Entry (only when New is clicked)
UI policy?
Help with code?
Thanks - Hope to see you Knowledge 2025
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-18-2025 08:28 AM - edited ā01-18-2025 08:30 AM
Hi @Jason Rooney ,
Based on my understanding, you want the choice value "Manual Entry" to be displayed only when creating a new Server record; otherwise, you want to remove this choice value from the "Discovery Source" field.
To accomplish this, you can write a client script as follows:
function onLoad() {
// Check if the current form is NOT a new record and if the current value of the 'discovery_source' field is NOT 'Manual Entry'.
if (!g_form.isNewRecord() && g_form.getValue("discovery_source") !== "Manual Entry") {
// If the conditions are met, remove the 'Manual Entry' option from the 'discovery_source' choice list.
g_form.removeOption("discovery_source", "Manual Entry");
}
}
Please note that if the "Discovery Source" field of an existing record already has the value "Manual Entry," it is not advisable to remove this choice value. Doing so would result in an empty field, which may not be desirable.
If this solution helps you then, mark it as accepted solution āāāļø and give thumbs up š!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-18-2025 08:28 AM - edited ā01-18-2025 08:30 AM
Hi @Jason Rooney ,
Based on my understanding, you want the choice value "Manual Entry" to be displayed only when creating a new Server record; otherwise, you want to remove this choice value from the "Discovery Source" field.
To accomplish this, you can write a client script as follows:
function onLoad() {
// Check if the current form is NOT a new record and if the current value of the 'discovery_source' field is NOT 'Manual Entry'.
if (!g_form.isNewRecord() && g_form.getValue("discovery_source") !== "Manual Entry") {
// If the conditions are met, remove the 'Manual Entry' option from the 'discovery_source' choice list.
g_form.removeOption("discovery_source", "Manual Entry");
}
}
Please note that if the "Discovery Source" field of an existing record already has the value "Manual Entry," it is not advisable to remove this choice value. Doing so would result in an empty field, which may not be desirable.
If this solution helps you then, mark it as accepted solution āāāļø and give thumbs up š!