Show error message on form

Community Alums
Not applicable

Hello

I want to how to show a message at the bottom of the field, not just pop up message. I just want to put error message at the bottom of the manager field if the manager is empty the error message will show.

3 ACCEPTED SOLUTIONS

Anand Kumar P
Giga Patron
Giga Patron

Hi @Community Alums ,

You can use below script on client script as per your requirment

var mange=g_form.getValue('manager_field_backedname');

if(mange==''){

g_form.showFieldMsg('manager_field_backendname', 'Manager field should not empty', 'error');

}

Please mark it as solution proposed and helpful if it serves your purpose.

Thanks,

Anand

View solution in original post

Sandeep Rajput
Tera Patron
Tera Patron

@Community Alums You can use  showFieldMsg method of g_form to show message below a field.

g_form.showFieldMsg('manager','Low impact response time can be one week','info');

View solution in original post

Amit Gujarathi
Giga Sage
Giga Sage

HI @Community Alums ,
I trust you are doing great.
Please find the below code for the same.

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }
    // Assuming 'manager' is the field name of the Manager field
    if (g_form.getValue('manager') === '') {
        // Displaying an error message
        g_form.showFieldMsg('manager', 'Please select a manager.', 'error');
    } else {
        // Clear any existing messages if the manager is selected
        g_form.hideFieldMsg('manager');
    }
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



View solution in original post

4 REPLIES 4

Anand Kumar P
Giga Patron
Giga Patron

Hi @Community Alums ,

You can use below script on client script as per your requirment

var mange=g_form.getValue('manager_field_backedname');

if(mange==''){

g_form.showFieldMsg('manager_field_backendname', 'Manager field should not empty', 'error');

}

Please mark it as solution proposed and helpful if it serves your purpose.

Thanks,

Anand

Sateesh Kumar D
ServiceNow Employee
ServiceNow Employee

Hello,

When do you want to show this message?

When user tries to save the form? -> If yes, then make sure manager field is not mandatory and the have a onSubmit client script with the script snippet mentioned by Anand in above reply.

If you need that message in some other instance let know, we might have to approach differently

Sandeep Rajput
Tera Patron
Tera Patron

@Community Alums You can use  showFieldMsg method of g_form to show message below a field.

g_form.showFieldMsg('manager','Low impact response time can be one week','info');

Amit Gujarathi
Giga Sage
Giga Sage

HI @Community Alums ,
I trust you are doing great.
Please find the below code for the same.

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }
    // Assuming 'manager' is the field name of the Manager field
    if (g_form.getValue('manager') === '') {
        // Displaying an error message
        g_form.showFieldMsg('manager', 'Please select a manager.', 'error');
    } else {
        // Clear any existing messages if the manager is selected
        g_form.hideFieldMsg('manager');
    }
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi