Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Using GetField with a repeating field?

Featured Replies

  • Newbies

In order to build a very dynamic layout I have the following scenario: Users can select multiple "Resources" from a checkbox set and then the associated text label and icon will appear elsewhere on the layout for each selected resource. Also, each resource has a status associated with it (e.g., new, updated, cancelled); the aforementioned icon for each resource will be determined by that resource's current status.

It works as follows:

1) User selects 0...n "resources" from a checkbox set (i.e., Resource1, Resource2, ...). This is stored in the field "Activity_Resources"

2) Each resource has a field for storing its current status, e.g., ResourceStatus_Resource1, ResourceStatus_Resource2 (note that they are all named with this convention" "ResourceStatus_" & Resource#)

3) A repeating calculated field (which is "recalculate as needed") is defined as: GetValue( Extend(Activity_Resources) ; Get( CalculationRepetitionNumber ) ). This repeating field is called "Activity_Resource Names" and basically is just a handy trick for converting a list of items in to a repeating field.

4) There is a custom function StatusIcon(Status) which returns the correct image file of the icon associated with the given Status.

So far, so good: My repeating field "Activity_Resource Names" dynamically displays the resources when the user selects (or de-selects) from the checkbox.

To display the proper icon, there's a second repeating calculation field (which is "recalculate as needed"):

CurrentStatuses = GetField("ResourceStatus_" & Activity_Resource Names[Get(CalculationRepetitionNumber)])

CurrentStatuses should be a repeating field containing the status for each of the resources. The purpose of this repeating field is merely to use as the parameter for the custom function: StatusIcon(CurrentStatuses[n])

My problem is that the repeating field CurrentStatuses doesn't get calculated properly via the "GetField" function--- only CurrentStatuses[1] works... Any other repeat after the first value is empty.

Any thoughts or comments are appreciated.

thanks

I am sorry - I stopped following at some point. I believe it was this part that threw me off:

2) Each resource has a field for storing its current status, e.g., ResourceStatus_Resource1, ResourceStatus_Resource2 (note that they are all named with this convention" "ResourceStatus_" & Resource#)

That doesn't sound like a good arrangement; why don't you have a table of Resources, where each "resource" is a record. Then you could display the selected resources, along with their status and any other attribute, in a portal.

---

BTW, I don't see Extend() in your formula, so that's probably why you're only getting the first repetition. Still, it looks like you're building a very complex device to achieve something that could be achieved much more simply.

Edited by comment

  • Author
  • Newbies

Comment,

The main reason that a relational model utilizing portals wasn't implemented here was because I inherited this db from a previous developer. The backbone of the system is the resources' statuses so I've been avoiding the prospect of rebuilding the whole thing (many layouts, scripts, calculated fields, etc).

Regarding Extend(), where do you suggest? I have two repeating calculated fields:

a) Activity_Resource Names[] = GetValue( Extend(Activity_Resources) ; Get( CalculationRepetitionNumber ) )

B) CurrentStatuses[] = GetField("ResourceStatus_" & Activity_Resource Names[Get(CalculationRepetitionNumber)])

I'm assuming that you're referring to the CurrentStatuses lack of Extend(). I understood that Extend() is only for use when defining a repeating field based on the calculation of a non-repeating field. In this case here, CurrentStatuses[] is calculated based on a repeating field-- so Extend() shouldn't be needed, correct?

thanks

I've been avoiding the prospect of rebuilding the whole thing

I am not sure that what you're doing is less work...

Regarding Extend(), I believe it should be something like=

Extend ( GetField ( "ResourceStatus_Resource" & Get ( CalculationRepetitionNumber ) ) )

This could probably be smartened by calculating the string instead of hard-coding it. OTOH, I wouldn't spend too much effort going in this direction.

Regarding your version, I suggest you remove the GetField() part, and see if it returns valid field names.

  • 5 weeks later...
  • Newbies

If a repeating field uses another repeating field (with the same number of repetitions), the calculation for each separate 'box' will automatically refer to the same repetition in the other field only. E.g. CurrentStatuses[3] will only 'see' Activity_Resource Names[3]. There's no need to specify the repetition as such, it won't even work, I think. In fact, it's practically impossible to specify any other repetition from another repeating field than the one you're on. It's purely 'horizontal'. The only exception is the first and only repetition of a non-repeater, which you can force to behave like a repeating field by using Extend().

So you might try:

CurrentStatuses[] = Extend( GetField( "ResourceStatus_" & Activity_Resource Names ) )

Activity_Resource Names is also a repeating field after all, so it should give you the corresponding repetition.

(Quickly tested (FMA12): I think this works)

HTH Peter

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.