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

Thanks again @uttkarshupa , do you have syntax example for 'persist' option?

You're welcome, here’s how you can use the persist option:

g_form.showFieldMsg('u_test', 'Please enter a valid value', 'error', false);   

[Here, false keeps the message persistent]

This will keep the message visible until you decide to clear it with g_form.clearFieldMsg() or based on some other condition. If version doesn’t support persist, you might have to manage the visibility manually.

Hope this helps, and if it works for you, a thumbs up would be awesome.



@uttkarshupa  Thanks you very much for your assistance! ithe message is still not stay even I've added false in the end of the g_form.showFieldMsg function.

Thanks for the update, If adding false to the g_form.showFieldMsg() still isn't working, it might be a version issue or something specific to the Workspace itself. Sometimes, certain configurations or customizations in the Workspace can cause unexpected behavior.

As a workaround, you can manually keep the message visible by ensuring no refresh or form re-rendering is happening after you show the message. You could try this:

1) Use setTimeout() to delay any field clearing or form changes after showing the message.
2) Or, you could try g_form.clearFieldMsg() only when you're ready to manually remove the message.

If this still doesn't work, it might be a backend issue or something deeper in the form rendering process.

Thank you @uttkarshupa , I apperciate it! I've made a combination of what you suggested and it solved the issue:

 

 var emailPattern = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
    if (!emailPattern.test(newValue)) {
        g_form.clearValue('run_email');
		setTimeout(function() {
			g_form.hideFieldMsg('run_email');
            g_form.showFieldMsg('run_email', 'Please enter a valid email address (i.e. name@company.com).', 'error');
        }, 500); // Delay of 500 milliseconds