Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Looping thru fields

Avatar

Not applicable
Hello,



I would liek to write a function that upon ready:form would check to see if some fields have some text in them and if so - make sure they are visible.



Currently I have this on ready:form:



myField = topmostSubform.Page1.StaffPrep.WhatsNew



if (myField.Prod.Prod_Note.rawValue.length==0) {

myField.Prod.Prod_Note.presence = "hidden";

myField.Prod.CheckBox1.value = "Off";

}

else {

myField.Prod.Prod_Note.presence = "visible";

myField.Prod.CheckBox1.value = "On";

}



How would I change this to check all 11 fields (which have names like HR_Note and Sales_Note and Misc_Note)?
0 Replies

Avatar

Level 2
How about create an array with all 11 field names, loop through the array to check the indivual fields.



Have you tried to accomplish this through the object validation under the value tab...?

Avatar

Not applicable
I have not - let me give that a try.



Thanks for responding.

Avatar

Not applicable
I have tried writing the loop but it seems to be over my head. Can anyone help me with this?



I need to loop thru 11 fields, check their length and make them visible or invisible.



Thank you

Avatar

Level 5
You can loop through each object in the hierarchy using things like nodes.length. Email me if you'd like a better explanation and some sample script showing how to do that.



Ryan D. Lunka

Cardinal Solutions Group

rlunka@cardinalsolutions.com

Avatar

Not applicable
Thanks for the offer. I will do that. In the meantime - is this on the right track?



var y = ['TextField1_note','TextField2_note','TextField3_note'];



for each (x in y) {

if (x.rawValue.length == 0) {

x.presence = "invisible"

}

else {

x.presence = "visible"

}

Avatar

Level 5
Also, I know that I sent you a better solution, but I noticed something revisiting this post. Using "x.rawValue.length == 0" is probably not the best way to go. If "x.rawValue" is null, "x.rawValue.length" will be undefined and so, your script will not enter the "if" statement. Use "x.rawValue == null" instead.



Ryan D. Lunka

Cardinal Solutions Group

rlunka@cardinalsolutions.com