Add a message under a field

Raji15
Tera Contributor

Hi, 

I have a variable named proxy and it has 4 options None, Yes, No, Not applicable. Whenever the user selecting Yes under the field I want a message "Archer request required" should populate. How to do that can anyone pls help. Thank you!

Gangadhar Ravi
Giga Sage

@Raji15 @You can implement this with field message please refer below post.

 

https://www.servicenow.com/community/itsm-forum/how-to-add-field-message-to-selectbox/m-p/579097#M15...

 

Please mark my answer correct and helpful if this works for you.

Sandeep Rajput
Tera Patron

@Raji15 You need to create an onChange client script on Proxy variable as follows.

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }

    // Check if the new value is 'Yes'
    if (newValue === 'Yes') {
        // Show a field message under the variable
        g_form.showFieldMsg('proxy', 'Archer request required', 'info');
    } else {
        // Clear the message if the value is not 'Yes'
        g_form.hideFieldMsg('proxy');
    }
}

Please mark my response helpful and accepted solution if it addresses your question.

Not working. The variable is inside the container. Is that cause any problem may be?

@Raji15 Shouldn't be an issue even if the variable is inside a container. Could you please share the variable name and the script you are tryring.