g_form.showFieldMsg() : Field message disappears as soon as its displayed in configurable workspace

Sanjay Nayak
Tera Contributor

Hello All,

I have a requirement for clearing out the value in 'Planned Effort(Hours)' field and show a field message under it if the value entered is less than 'Planned Effort for Current FY' field [Both are floating point number fields].

SanjayNayak_2-1714460795632.png

I have written an onChange client script on 'Planned Effort(Hours)' field in order to do this validation. This client scripts works properly in native UI showing the field message and the message is retained after the value is cleared out.

Client script [UI Type = All, Type = onChange, Field = Planned Effort(Hours)]:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '' || g_form.getValue('planned_effort_for_current_fy') === '') {
        return;
    }

    if (parseFloat(g_form.getValue('planned_effort_for_current_fy')) > parseFloat(newValue)) {
        g_form.clearValue('estimated_planned_effort_hours');
        g_form.showFieldMsg('estimated_planned_effort_hours', 'The value should be less than Planned Effort(Hours)', 'error');
    }
}
In a configurable workspace, when I'm entering a value in 'Planned Effort for Current FY' field and adding a smaller value in 'Planned Effort(Hours)' field, this script clears out the value in 'Planned Effort(Hours)' field and displays the field message for a fraction of second and then disappears. I need the field message to be retained as it does in native UI.
Parallel observation:
When I'm trying to display an error message instead of the field message, the same error message appears twice. I have checked and verified that the client script is not duplicated and there is only one script running on change of the field in consideration. In native UI the error message appears only once. 
 
On the same form, the validation on date type field using the same code as above works fine. The date fields are cleared out and field message is retained on the form as expected.
 
Please let me know if anyone has faced this issue only in configurable workspace and how it can be rectified.