showFieldMsg is not working in workspace

Sri_9
Tera Contributor

Hi,

I'm trying to show field msg in workspace using g_form.shoFieldMsg() after clearing the value, the value is getting cleared but the message stays for a fraction of second and disappears. Please suggest how to fix this issue.

Thanks in advance.

15 REPLIES 15

Dnyaneshwaree
Mega Sage

Hello @Sri_9 , Please elaborate your issue.
If i am able to understand your issue, check that is there any ui policy/script that is setting the required field hidden? 

tpeleg
Tera Expert

Hi @Sri_9 , did you ever find solution for this issue? Thx

uttkarshupa
Tera Expert

The problem occurs because when you use g_form.clearValue(), the form might be refreshed or re-rendered almost immediately, which results in the message disappearing right after being shown. By adding a slight delay before clearing the value, you can give the message enough time to stay visible.

 

var test = g_form.getValue('u_test');
var regex = /^[^, ]+$/;

if (test != '' && !regex.test(test)) {
g_form.showFieldMsg('u_test', 'Please enter a valid value', 'error');

setTimeout(function() {
g_form.clearValue('u_test');
}, 100);
}

By adding this delay, you prevent the message from disappearing too quickly when the value is cleared.

If this works for you, kindly accept this solution and give it a thumbs up.

tpeleg
Tera Expert

Thank you @uttkarshupa! , it seems like a Workspace issue, as it works properly at the backend view.

I'm looking for a solution that will keep the error message permanently...

You're welcome! Yeah, it seems like a Workspace issue. If you're looking to keep the error message permanently, try using the persist option with g_form.showFieldMsg() (if available). This should keep the message until you manually remove it. Let me know if that works for you.