Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Create records based on matrix


Recommended Posts



I've got a table with 2 global text fields:


gListGroups: contains a list of group names

gListParameters: contains a list of parameter names


and 2 normal text fields


parameter: a single parameter (which I use for a statistical calculation)

group: for each parameter the group it belongs to.


Suppose gListGroups contains 2 values and gListParameters 3.




group 1

group 2



parameter 1

parameter 2

parameter 3


If we put this is a matrix we get the following combinations


recordnumber parameter group

1 parameter 1 group 1

2 parameter 1 group 2

3 parameter 2 group 1

4 parameter 2 group 2

5 parameter 3 group 1

6 parameter 3 group 2




What I need is a script that creates as many records as there are in the matrix and for each records sets the Parameter and Group fields according to the matrix above.


Now I know that if you want to create as many records as there are in a single global text field (e.g. gListParameters), you define a global number field (gParameterNumber) which -- by means of a loop -- is increased by 1 every time the loop is performed. Using the MiddleValues function you can insert the appropriate value in the Parameter field. As soon as the number field equals the amount of values in the text field, the loop is exited:



Set Field [TABLE::gParameterNumber;0]

[indent]Set Field [TABLE:gParameterNumber;TABLE:gParameterNumber+1]
New Record/Request
Set Field [TABLE::Parameter;MiddleValues (TABLE::gListParameters;TABLE::gParameterNumber;1]
Exit Loop If [TABLE:gParameterNumber = ValueCount (TABLE::gListParameters)]

End Loop


This script would of course only create 3 records:


recordnumber parameter


1 parameter 1

2 parameter 2

3 parameter 3


I assume it is somehow possible to nest a second loop in the first, which in a similar way goes through the values of TABLE::gListGroups ...

I've been trying to figure out how this would work but i haven't got a CLUE!!







Link to comment
Share on other sites

A complex post, but here are a couple questions that might help clarify things.


1) you have a list (a repeating field - an array) stored in a global field? Outside of the fact that repeating fields are a legacy concept - a holdover from an earlier day - manipulating repeating fields is tougher than dealing with multiple records.


You can use, getRepetition, to do this, but it add code complexity as well.


You are going to have to loop through each record, then SET FIELD a set of concatenated elements to get what you want. Looping through repetitions is something I don't know how to do - the typical construct for anything in FM today, is record based.


If you 1) either had multiple globals to replace each of the repetitions in the 2 globals that you have today, or 2) had a TO with multiple records that matched each of these repeating elements, then a looping script might be easier.


Someone else may have a better solution, but I'd recommend changing the way the categorization names are stored, to start. My $0.02 worth.....

Link to comment
Share on other sites

  • Create New...

Important Information

Terms of Use