Field Validation on form Portal

Dipu_9999
Tera Expert
In the form, there is a field called "Location" which has multiple choices. When a user selects a location and there is no corresponding full name value for that location, it displays a blank blue space as shown in the attachment. I want to remove that blank blue space when the full name is not available. How can I modify the onChange client script to achieve this requirement?
function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;     
    }

    if (newValue != "") {
        var ga = new GlideAjax('SBIncidentUtils');
        ga.addParam('sysparm_name''getLocationDetails');
        ga.addParam('sysparm_location', newValue);
        ga.getXMLAnswer(updateField);
    }

    function updateField(answer) {
     if (answer != "noValue" && answer != '') {
            g_form.showFieldMsg('cmn_Location', answer, 'info'true);
            
        }
    }
}
1 ACCEPTED SOLUTION

Anand Kumar P
Giga Patron
Giga Patron

Hi @Dipu_9999,

You can use below script it will work

if (newValue != "") {
var ga = new GlideAjax('SBIncidentUtils');
ga.addParam('sysparm_name', 'getLocationDetails');
ga.addParam('sysparm_location', newValue);
ga.getXMLAnswer(updateField);
} else {
// Clear the info message if newValue is empty
g_form.hideFieldMsg('cmn_Location');
}

function updateField(answer) {
if (answer != "noValue" && answer != '') {
g_form.showFieldMsg('cmn_Location', answer, 'info', true);
} else {
// Clear the info message if answer is "noValue" or empty
g_form.hideFieldMsg('cmn_Location');
}
}

Please mark helpful and solution proposed if it works.

Thanks,

Anand

View solution in original post

2 REPLIES 2

Anand Kumar P
Giga Patron
Giga Patron

Hi @Dipu_9999,

You can use below script it will work

if (newValue != "") {
var ga = new GlideAjax('SBIncidentUtils');
ga.addParam('sysparm_name', 'getLocationDetails');
ga.addParam('sysparm_location', newValue);
ga.getXMLAnswer(updateField);
} else {
// Clear the info message if newValue is empty
g_form.hideFieldMsg('cmn_Location');
}

function updateField(answer) {
if (answer != "noValue" && answer != '') {
g_form.showFieldMsg('cmn_Location', answer, 'info', true);
} else {
// Clear the info message if answer is "noValue" or empty
g_form.hideFieldMsg('cmn_Location');
}
}

Please mark helpful and solution proposed if it works.

Thanks,

Anand

Dipu_9999
Tera Expert

Thanks