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!

1 ACCEPTED SOLUTION

 

Hi @Raji15,

Containers are used to display variables either as a single field in a row or two fields in a row.

 

I Tried in my PDI , It is Working Fine

The issue is not related to the containers. Please review the backend values of the variables and choices, and try again.

Thanks and regards,
Badrinarayan"

View solution in original post

10 REPLIES 10

Badrinarayan
Tera Guru

Hi @Raji15 , 

 

To display a field message beneath the field when an option is selected, you can use the showFieldMsg() function.

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) {
        return; // Don't do anything while the form is loading
    }

    // Clear any previous messages
    g_form.hideFieldMsg('Your_field_name');

    // Show messages based on the new value
    if (newValue == 'yes') {
        g_form.showFieldMsg('Your_field_name', 'Message 1', 'error');
    } else if (newValue == 'no') {
        g_form.showFieldMsg('impact', 'Message 2', 'error');
    }
}

 

 

Please mark my solution as helpful and accept it if your issue has been resolved.

 

Thanks Regards

Badrinarayan

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

 

Hi @Raji15,

Containers are used to display variables either as a single field in a row or two fields in a row.

 

I Tried in my PDI , It is Working Fine

The issue is not related to the containers. Please review the backend values of the variables and choices, and try again.

Thanks and regards,
Badrinarayan"

Abhishek_Thakur
Mega Sage

Hello @Raji15 ,

Please follow this KB article to show a field message for the variable inside the container.

Configuring 'showErrorBox' and 'showFieldMsg' with hideFieldMsg for a better UI experience - Support...

 

Please mark my answer as accepted solution and give thumbs up, if it helps you.

Rajesh Chopade1
Mega Sage

Hi @Raji15 

When dealing with variables inside containers, you still use the g_form.getValue() and g_form.showFieldMsg() functions, but ensure that the variable name you’re using in the script matches the name defined in the catalog item.

 

 

// Client Script to show message based on proxy variable selection
(function() {
    // Get the selected value of the 'proxy' variable
    var proxyValue = g_form.getValue('proxy');
    
    // Check if the value is 'Yes'
    if (proxyValue == 'Yes') {
        // Display a message to the user
       // g_form.addInfoMessage('Archer request required');
       g_form.showFieldMsg('Your_field_name', 'Message 1', 'error');
    } else {
        // Clear the message if the value is not 'Yes'
        g_form.clearMessages();
    }
})();

 

 

 

i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

rajesh