Showing a Field message causes the form to jump to the top

SAS21
Tera Guru

Have Choice Field 'price' . If price - option 'A ' is selected displaying another field 'Cause', using an UI policy. 

On change of Price, If option A is selected, Cause should be visible and have to show a field message. If Price is 'option B', display Cause and show another field message.

created on change client script for 'price' . But the field message for option A is causing the form to jump to the top. How can we avoid this?

Here is the code tried on Change of Price

if (price == 'option A') {
g_form.hideFieldMsg('u_cause', true);
g_form.showFieldMsg('u_cause', 'unique product', 'info');
} else if (price == 'option B') {
g_form.hideFieldMsg('u_cause', true);
g_form.showFieldMsg('u_cause', 'only one product available', 'info');
}

 

for Option B form stays as it is but when selected option A , form jumps to the top

 

Appreciate the Help!

 

 

1 ACCEPTED SOLUTION

New Developer_S
Giga Sage

Hi @SAS21 ,

 

Please try to use below format to prevent form from Scrolling

g_form.showFieldMsg('<FIELD_NAME>', '<MESSAGE>', 'info', false);

 If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

View solution in original post

2 REPLIES 2

New Developer_S
Giga Sage

Hi @SAS21 ,

 

Please try to use below format to prevent form from Scrolling

g_form.showFieldMsg('<FIELD_NAME>', '<MESSAGE>', 'info', false);

 If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

Community Alums
Not applicable

Hi @SAS21 ,

Please try below script this will help you 

Please create the onChange client script on particular values for example in your case price

 

alert("va = " + newValue);
    if (newValue == 'option_a') {//backend value of option_a
        g_form.hideFieldMsg('u_cause', true);
        g_form.showFieldMsg('u_cause', 'Unique Product', 'info');
    } else if (newValue == 'option_b') {//backend value of option_b
        g_form.hideFieldMsg('u_cause', true);
        g_form.showFieldMsg('u_cause', 'Only one product available', 'info');
    }else{
		g_form.hideFieldMsg('state', true);
	}

 

 

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

Thanks and Regards 

Sarthak