What is the significance of newValue == '') { return; }

Community Alums
Not applicable

Hi,

In the below script, what is the significance of newValue == '') { return; }. Kindly help.

Regards

Suman P.

 

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

 

1 ACCEPTED SOLUTION

Munender Singh
Mega Sage

Hi,

 

It determines that if on change of field value, if the new value is "" then, the script would not run. Similarly, isLoading signifies if the form is still loading then, script won't run further.

 

Regards,

Munender

View solution in original post

4 REPLIES 4

Samaksh Wani
Giga Sage
Giga Sage

Hellp Dava_P

 

newVaIue— Value of the control field after the change. For example, if the value of Assigned to changes from Runjay to Suman, the value of the parameter newValue will be Suman.

 

In the Scenerio, If newValue == ' ', that means, your value is not yet change or set to another value, it is still blank, so in that case flow logic will return nothing;

 

Plz Mark my Solution as Accept, If you got help or understanding from it.

 

Regards,

Samaksh

Munender Singh
Mega Sage

Hi,

 

It determines that if on change of field value, if the new value is "" then, the script would not run. Similarly, isLoading signifies if the form is still loading then, script won't run further.

 

Regards,

Munender

Sandeep Rajput
Tera Patron
Tera Patron

@Community Alums This if check is usually placed in all the onChange client script to check if the form isLoading or if the new value is empty. As in both the cases, no further processing is needed and control can be returned to execute other scripts.

 

=== (Triple equals) is a strict equality comparison operator in JavaScript, which returns false for the values which are not of a similar type. This operator performs type casting for equality. If we compare 2 with “2” using ===, then it will return a false value.

 

Source:  https://www.guru99.com/difference-equality-strict-operator-javascript.html

Samaksh Wani
Giga Sage
Giga Sage

Hello @Community Alums 

 

I have also given the Same Example of Script,

 

Can you plz mark my Solution as Accept, It will help other users to reach the post.

 

Regards,

Samaksh