10 Replies Latest reply on Oct 14, 2016 7:42 AM by beverly

# Determine the number of repetitions in a repeating field

I haven't needed to work with repeating fields for ages. I need to work out how many repetitions a repeating field is defined to have. Specifically this is in a loop to work out when to stop. This seems to work:

IsValid ( GetRepetition ( Job::Risk_Survey_Physical_Q ; \$counter ) )

When \$counter > number of repetitions, isValid returns zero.

If there is a better way, let me know.

Hope this helps.

• ###### 1. Re: Determine the number of repetitions in a repeating field

HTH

Chris Cain

Extensitech

• ###### 2. Re: Determine the number of repetitions in a repeating field

would this help:

FieldRepetitions

beverly

• ###### 3. Re: Determine the number of repetitions in a repeating field

The FieldRepetitions function returns the number of repetitions displayed on the specified layout (as opposed to the number of repetitions defined).

The expression I posted determines the defined repetitions independent of layout (as long as the current layout's TO is related to the field's table).

• ###### 4. Re: Determine the number of repetitions in a repeating field

FieldType ( fileName ; fieldName ) will give you 4 words.

The last one is a number being the number of repetitions defined for the named field.

• ###### 5. Re: Determine the number of repetitions in a repeating field

As explanation, the aim was to get a calculated repeating field to display a list of values. Here is what worked for me:

---

Let (

[

n = Get ( CalculationRepetitionNumber ) ;

vals = List ( values )

] ;

Case (

IsValid ( GetRepetition ( Job::Risk_Survey_Physical_Q ; n ) ) ;

GetValue ( vals ; n )

)

)

-----

• ###### 6. Re: Determine the number of repetitions in a repeating field

Indeed it does! This expression calculates from any context, too.

Many thanks.

• ###### 7. Re: Determine the number of repetitions in a repeating field

ah! yes! another one of those Design functions we forget.

Thanks, Ralph!

beverly

### Aggregate functions work successfully with repeating fields.

Simply List ( repeatingField ) function turns the values of repeating field as a list :

Field[1]Field[2]Field[3]Field[4]
ACC

List turns as a result:

A

C

C

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

repeatingField[Number] syntax is working exactly as GetRepetition ( repeatingField ; number )

Field[1], Field[2], Field[3] ... Field[n]

Last ( repeatingField ) function turns the last value of repeating field.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Fahri

• ###### 9. Re: Determine the number of repetitions in a repeating field

You can talk to every repetition cell simply indicating its number in [ ] , like you do with an array.

Let (\$i = 5; IsEmpty (YoutRpField[\$i]  )) will tell you if the 5th repetition is empty.

• ###### 10. Re: Determine the number of repetitions in a repeating field

Yes, List() returns the NON-empty values of repeating field.

Last() is the final NON-empty repeat of a repeating field - not so helpful if you want the empties, too.

for example, a chart of data per month (12 repeats) will need the blank values, too, to see an entire year.

beverly

p.s. NOT an endorsement for repeating fields, but they do have useful attributes at times.