4 Replies Latest reply on Jul 26, 2013 8:11 AM by DranLang

    IF CONDITION won't work properly in a repeating field

    DranLang

      Title

      IF CONDITION won't work properly in a repeating field

      Post

           Hi everyone!  Early this morning I got a call from a friend of mine asking if I could help him with his FM's IF condition.  To begin with, He has a 3 repeating fields (Class, Major, and Building; Class has choices to choose from Morning, Afternoon and Evening).  Class is a pulldown field so when he choose a class the fields Major and Building will automatically be populated by values related to the class and which are referenced from a different table.  I checked his use of the IF condition (and it seems correct, but I can't be sure since I'm also new to FileMaker), the IF condition intended for the Major field is written as follows:

           If(Class = TABLE1::ClassGroup; TABLE1::Maj; "").

            

           For some reason, it only gives the result correctly if the class chosen is not the same as the first one selected (Example: The first class chosen is Morning, the Major field gives out the Moajor class available in the morning (Computer Science), but if you choose the same Morning Class for the second row (Class[2]) Major[2] only gives you empty result) but if you select Afternooon or evening first it will give the correct result.

            

           Is the IF condition needs to be changed for repeating fields? Because when he tried to use it in a portal and not a repeating fields it works just fine.

            

            

           Thanks everyone!

        • 1. Re: IF CONDITION won't work properly in a repeating field
          philmodjunk

               WHen your refer to a repeating field with this syntax: TableOccurrenceName::RepeatingFIeldName, you are referring to the data in the first repetition of the repeating field in most cases.

               I would recommend that you not use repeating fields for this purpose but to replace them with a related table where each record takes the place of a repetition in the current setup. That not only will eliminate the issues with your IF function, but also makes for a much more flexible data structure.

          • 2. Re: IF CONDITION won't work properly in a repeating field
            DranLang

                 Thank you Phil, I would relay that to my friend.  One more question, I wrote a script for my friend's project which would create a new record but it didn't work properly, the Job ID is incrementing correctly but the field values in the portal won't empty and if I change something it will also appear in the first record that was created. Part of the script is "New Record/Request", is it possible to have those fields in the portal to empty out without afffecting the previous record created so that users can add items in the field again but having a different Job ID?

                 Go to Layout["LAYOUT NAME"(TABLE NAME)]

                 Go to Record/ Request/Page [Last]

                 Set Variable ........................

                 New Record/Request

                 Set Field [TABLE NAME; Var + 1)

                  

            • 3. Re: IF CONDITION won't work properly in a repeating field
              philmodjunk

                   All you need to create a new record is New Record/request in a script or new record from the records menu. Job ID should be an auto-entered serial number so just the act of creating a new record should be all that's need for a new record to receive a new and unique jobID value.

                   I can't tell from your post what that has to do with a "Portal" as that emplies a relationship to a related table. If a portal displays the wrong data, either your relationship is incorrect, a portal filter is incorrect or a record or record does not have the correct value in a match field.

              • 4. Re: IF CONDITION won't work properly in a repeating field
                DranLang

                     Thanks Phil, I got it working now.  You were right about the use of JobID as being an auto-entered serial number and it was in the relationship of the tables where the problem occured.  Again, thank you so much that for more than 2 months I've been using FileMaker I've learned a lot specially here in this forum.