## Looping through cell in table

Jodi1725

Total Posts

113

Likes

6

2

Jodi1725

Total Posts

113

Likes

6

2
Jodi1725

19-11-2015

Hi all!

I have been digging but can't find my answer.  I have a table that you can add rows to.  In the same cell in each row I have to validate if the number in the field starts with a 4 or 5 ( the number is a total of 6 digits long).  I have java script that validates the 4 or 5.  but I need to loop through all the rows for that cell. Right now just validates on the first row.

Help!

Thank you!

Jodi

var Grant = Main.PreApproved.Table1.Row1.Fund.rawValue

var GrantFund = Grant.charAt(0)

if  (GrantFund == 4 || GrantFund == 5).......

#### Accepted Solutions (1)

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

269

372

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

269

372
_Bruce_Robertson
MVP

21-11-2015

Hi,

If you table has only one Row object that repeats (as opposed to a Row1, Row2, ...) you should be able to use;

var rows = Main.PreApproved.Table1.resolveNodes("Row1[*]");

for (var i = 0; i < rows.length; i++) {

var row = rows.item(i);

var GrantFund = row.Fund.isNull ? 0 : row.Fund.rawValue.charAt(0);

if  (GrantFund == 4 || GrantFund == 5) {

//...

}

}

Regards

Bruce

Jodi1725

Total Posts

113

Likes

6

2

Jodi1725

Total Posts

113

Likes

6

2
Jodi1725

31-01-2018

Hey Bruce!

I actually figured it out!  I used Loop Through Subform Instances  and used this code.

expenseReport.#subform[0].validate2::click – (JavaScript, client)
var vItems = expenses.expense.all;
for(i=0; i<vItems.length; i++)

if (vItems.item(i).description.rawValue == null)
{
xfa.host.messageBox("Missing description field");
break;
}

}

Took me a few tries to get it to work but it did Thanks!

Jodi

Jodi1725

Total Posts

113

Likes

6

2

Jodi1725

Total Posts

113

Likes

6

2
Jodi1725

31-01-2018

Hey Bruce!

Long time no talk! Hope you are doing well!  I have another repeating issue that I can't get to work

I once again am trying to validate through a repeating subform, but this is just the subform.  I have tried to manipulate the different code you sent me but I am just getting validation on the first subform not the repeated ones.  What am I missing?
Thank you for all your help!

Jodi

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

269

372

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

269

372
_Bruce_Robertson
MVP

08-03-2016

Hi Jodi,

Ok, I think I see what is happening, and each campus has a different Grants and Contracts?  Have a look at this update, https://sites.google.com/site/livecycledesignercookbooks/home/AwardPaymentAuthorization12_2015_2.pdf..., I've taken all the emails generation stuff out of the loop so it'll happen once all the mandatory checks have been made.

Hope it's getting closer.

Regards

Bruce

Jodi1725

Total Posts

113

Likes

6

2

Jodi1725

Total Posts

113

Likes

6

2
Jodi1725

07-03-2016

Hey Bruce!

You are awesome!

What it is supposed to do is check the Fund field for each person that is added.  If any one of the people have a fund that has a 4 or 5 as the first number, then the whole form needs to be sent to the grants and contracts office first for approval.  when Grants and contracts approves it they will then sent to Payroll.

If none of the fund fields have a 4 or 5 then the form goes directly to payroll.

Right now it seems to want to send an email for each of the form fields, vs. emailing just once.

Does that make sense?

You help has been invaluable!

Thanks!

Jodi

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

269

372

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

269

372
_Bruce_Robertson
MVP

04-03-2016

Hi Jodi,

Have a look at this version, https://sites.google.com/site/livecycledesignercookbooks/home/AwardPaymentAuthorization12_2015_2_wor...

Seems the repeating subform is Awardees (not PreApproved?), and then within that you need to repeat over Table2 (not Table1).

Also I assume GFY is meant to be row.Fund.rawValue (not GrantFund?)

Not sure I got all this right, if not give me a description of what the code is meant to do.

Regards

Bruce

Jodi1725

Total Posts

113

Likes

6

2

Jodi1725

Total Posts

113

Likes

6

2
Jodi1725

04-03-2016

Hi Bruce!  I know it has been a long time but things around here don't always  move fast    I am finally trying to put in this looping through subforms but I am not having much luck.  I have uploaded the doc to google docs.  Here is the link.  If you can help that would be awesome!  Thank you!

Jodi

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

269

372

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

269

372
_Bruce_Robertson
MVP

16-12-2015

Hi Jodi,

Should be something like;

var tables = Main.resolveNodes("PreApproved[*]");

for (var j = 0; j < tables.length; j++) {

var table = tables.item(j);

var rows = table.Table1.resolveNodes("Row1[*]");

for (var i = 0; i < rows.length; i++) {

var row = rows.item(i);

var GrantFund = row.Fund.isNull ? 0 : row.Fund.rawValue.charAt(0);

if  (GrantFund == 4 || GrantFund == 5) {

//...

}

}

}

Could be some changes you need to make depending on your form structure.  If you can't get it to work upload your form to Dropbox, or Google Docs (or somewhere) and post a link to it here.

Regards

Bruce

Jodi1725

Total Posts

113

Likes

6

2

Jodi1725

Total Posts

113

Likes

6

2
Jodi1725

15-12-2015

Hey Bruce,

Since you were so helpful last time.  Do you know how you would loop through the subform that the table is in?  I have a button that duplicates the subform so the users can add additional information.  So I need to look through each duplicated subform and also check the cell in the row.

Any ideas?

Jodi

Jodi1725

Total Posts

113

Likes

6

2

Jodi1725

Total Posts

113

Likes

6

2
Jodi1725

07-12-2015

Hey Bruce,

Since you were so helpful last time.  Do you know how you would loop through the subform that the table is in?  I have a button that duplicates the subform so the users can add additional information.  So I need to look through each duplicated subform and also check the cell in the row.

Any ideas?

Jodi

Jodi1725

Total Posts

113

Likes

6

2

Jodi1725

Total Posts

113

Likes

6

2
Jodi1725

24-11-2015

Bruce you are the man!!!  It worked!

Thank you so much for the help!
Have a great Thanksgiving!

Jodi

Jodi1725

Total Posts

113

Likes

6

2

Jodi1725

Total Posts

113

Likes

6

2
Jodi1725

23-11-2015

Awesome!  Thank you Bruce!  I will try it tomorrow (too many meetings today )

When I was lookoing at the Javascript I would get confused byt the (var i = 1; i< rows.lenght; i++) part.
I never understood how to to it or what it meant.  Thank you again!

I will let you know how it goes!

Jodi