2 Replies Latest reply on Aug 22, 2011 7:26 PM by dmusicfiler

    need set field help in FMP 10 Advanced

    dmusicfiler

      Title

      need set field help in FMP 10 Advanced

      Post

      Re-edited Sunday night:

      I have a table that tracks songs in a list. Each year, the list gets updated once in the fall semester. To create about 100 new records in the table, I have created a layout for entering the new songs, using a portal to a second occurrence of the table related with a key that is a concatenated year and month so that only the new list for the year being entered will show.

      The image attached shows a script to create new records using a global number for the number of new records. In the script, I made all the references to fields based on a duplicate occurrence of the table, but maybe that doesn't matter? 

      The records do get created by the script and show up in the portal, but none of the set field data works.

      I cannot get set field to work using "set field", "set field by name", or even by "set variable", then setting a field to that variable in the new record. Should I revert to cutting and pasting? I wanted to avoid it and the layout switching that involves.

      All fields are matched by text or number type.

      Maybe I don't know how to specify set field info properly?

      1. When clicking on specifying a field, is that just the name of the field or a calculation for defining the field or both?

      2. Is the calculation below it just for calculating the value?

      3. Does repetition only refer to deriving data from repeating fields?

      4. I tried replacing the default "1" with a calculated value. Is that wrong?

      5. Do I need to add steps to enter the fields first before setting the field?

      6. Is there something I need to know about making multiple set fields in one loop of the script?

      7. Would it work better to concatenate the data from multiple fields and then parse that into the new fields?

      8. Does set field not work on a self-join?

      What am I missing? Is there someone that can help me understand how to correctly set fields? I have looked at other entries in the forums but none of them are specific as to exactly what to click on and what to enter.

      Thanks very much.

       

       

       

       

      song_script.png

        • 1. Re: need set field help in FMP 10 Advanced
          philmodjunk

          To create about 100 new records in the table, I have created a layout for entering the new songs, using a portal to a second occurrence of the table related with a key that is a concatenated year and month so that only the new list for the year being entered will show.

          I don't see any reference to a portal to a self join in your script. Exactly how are you using this portal?

          Your script shows that a number is entered into a field named g_number_NEWsongs and then you create that many new records while attempting unsuccessfully to use set field by name to assign the contents of gVALUE_BarrierVersion to the BarrierVersion field of each newly created record.

          A lower case g as the first letter of a field's name often is used by developers to identify a field for which global storage was selected in field options. Do g_number_NEWsongs and gVALUE_BarrierVersion have global storage specified in field options?

          Assuming that global storage is specified for these two fields, this script should create the specified number of songs with the version value from the gVALUE_BarrierVersion copied into each such new record:

          Go to Layout ["NEW_Barriers" (Barrier levels)]
          Set Variable [$BarrierCounter; Value: barrier Levels::g_number_NEWsongs]
          Loop
             Exit Loop if [$BarrierCounter = 0]
             New Record/Request
             Set Field [Barrier Levels::barrierVersion; barrier Levels::gVALUE_BarrierVersion]
             Set Variable [$BarrierCounter ; Value: $BarrierCounter - 1]
           End Loop

          Problems getting the right syntax for set field is quite common with new users:

          When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

          1. When clicking on specifying a field, is that just the name of the field or a calculation for defining the field or both?

          With set field, you are just selecting the name of the field to the left of the semi colon. If using set field by name, this is a calculation whose value is intended to be the table and name of the field to be modified by this step. It should return a value with the format: Tablename::FieldName.

          2. Is the calculation below it just for calculating the value? See info above on setting up set field.

          3. Does repetition only refer to deriving data from repeating fields? Yes, and since repeating fields are rarely used, this is where the confusion comes in. The specify button next to the repetition box is for creating a calculation used to determine the repetition to be modified in a repeating field. If you use it by mistake here, you'll get Set Field [Table::Field [calculation expression here]] --which does nothing, because there is no calulated result.

          4. I tried replacing the default "1" with a calculated value. Is that wrong? If you mean the 1 in the repetition field, yes this was a mistake.

          5. Do I need to add steps to enter the fields first before setting the field? No. this is not necessary. The fields modified by set field do not even have to be present on the layout and set field still works provided that the current layout is the correct layout.

          6. Is there something I need to know about making multiple set fields in one loop of the script? It seems lies with ethier this "portal" that does not have any obvious purpose here or in inccorrect syntax in your set field step.

          7. Would it work better to concatenate the data from multiple fields and then parse that into the new fields? I don't see any multiple fields here in your script. What values would those be? Generally, if you have several values to enter into fields of the new record, you can use a variable or a global field for each.

          8. Does set field not work on a self-join? Set field works on a self-join just like any other related table, but there is no reference to the table occurrence name of the self join or any other related table in your current version of this script.
           

          • 2. Re: need set field help in FMP 10 Advanced
            dmusicfiler

            Hmm, it wasn't syntax. My global fields weren't global. I thought I set them, but hadn't...drrrrr. But your explanation of what to click on helped too. None of the books or manuals are specific about the third specify button next to repetition being only for repetitions...your explanations were very helpful.