Newbies BriSchnei Posted July 14, 2012 Newbies Posted July 14, 2012 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
comment Posted July 14, 2012 Posted July 14, 2012 (edited) 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 July 14, 2012 by comment
Newbies BriSchnei Posted July 14, 2012 Author Newbies Posted July 14, 2012 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 ) ) 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
comment Posted July 15, 2012 Posted July 15, 2012 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.
Newbies Peter Bouma Posted August 14, 2012 Newbies Posted August 14, 2012 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
Recommended Posts
This topic is 4854 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now