How to write the script

PRAGHATIESH S
Tera Expert

Hi,

I have created two variable like "Value" (single line txt variable) and "Notes"( html variable), when we fill value field less than 10000, it needs to show the Notes.

I tried with UI policy, but somehow it's not working.

 

Can anyone help here.

3 REPLIES 3

Sid_Takali
Kilo Patron
Kilo Patron

Hi @PRAGHATIESH S you can use below like script 

var valueLength = g_form.getValue('value').length;
    if (valueLength < 10000) {
        g_form.setVisible('notes', true);
    } else {
        g_form.setVisible('notes', false);
    }

Mark Manders
Mega Patron

You need to change the field type of your first variable. A single line text field doesn't recognize '10.000' as a number so you can't query to 'less than'.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Vrushali  Kolte
Mega Sage

Hello @PRAGHATIESH S ,

 

You can try to achieve it by creating on change of "Value" catalog client script as below -

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
  //add the below code here if you need to evaluate condition for on load
        return;
    }

    // Parse the value to an integer
    var value = parseInt(newValue);

    // Check if the value is less than 10000
    if (value < 10000) {
        g_form.showFieldMsg('Notes', 'Please provide additional notes.', 'info');
        g_form.setDisplay('Notes', true);
    } else {
        g_form.setDisplay('Notes', false);
    }
}

 

If my answer solves your issue, please mark it as Accepted ✔️& Helpful👍!