New Server - Manual Entry

Jason Rooney
Tera Contributor

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

1 ACCEPTED SOLUTION

debendudas
Mega Sage

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.

 

debendudas_0-1737217792635.png

 

If this solution helps you then, mark it as accepted solution ‌‌✔️ and give thumbs up 👍

View solution in original post

1 REPLY 1

debendudas
Mega Sage

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.

 

debendudas_0-1737217792635.png

 

If this solution helps you then, mark it as accepted solution ‌‌✔️ and give thumbs up 👍