3 Replies Latest reply on May 21, 2014 12:03 PM by lordhellfire

    Scripting error: field not on layout, but set anyway?

      Title

      Scripting error: field not on layout, but set anyway?

      Post

           I am running into an odd problem.  I have a script that creates a new record, linking it back to a parent record.  It starts on the source record on a layout base in TABLE_A - copying information from that record; it then goes to another layout based on TABLE_A and sets a bunch of fields; then it goes to a third layout based on TABLE_A.  However, it gives an error when it moves to the third layout:

           "??? is defined to require a value, but it is not available on this layout.  Use another layout to assign a value to this field."

           I can 'revert' or 'OK'.  The field that it is complaining about isn't on the layout (like it says), but the value still gets set correctly.  The odd part is that this error doesn't show up for every source record, only for some source records.

           The field it is complaining about is defined as:  Number, Require-Unique, Allow Override.

           Anyone have any ideas what is going on?  The fact that it doesn't happen for all source records is the real issue, it seems.  I could just throw that field onto the layout in the gutter area to solve the problem, but I am trying to understand why it is complaining only for some source records.

            

           Thanks,

           J

        • 1. Re: Scripting error: field not on layout, but set anyway?

               Amazing what just typing it out can do for you...

               I think I figured out the problem.  The error message was misleading me.  The problem was that, as part of the error said, there was already a record with that value, so it would have been a duplicate value.  Doh!

               So what's up with the red-herring of adding the field to a layout?

                

               --  J

          • 2. Re: Scripting error: field not on layout, but set anyway?
            philmodjunk

                 If all your layouts are based on Table A, why change layouts at all? Set field can update fields without them being physically present on the layout.

                 It is not possible to be able to tell you how to correct the specific validation error that you are getting without more information. It's possible that a commit records event is tripping the error and then, when the script continues after the error, it then is set to the desired value and there are a number of possible reasons why it is only triped part of the time. You might also check to see if maybe the value in the field is not unique.

                 You may find it useful to set up a "utility layout" based on table A where all fields are present. Then redesign your script to go to this one layout to set the needed values to the needed fields and then return to the original layout or where ever you need it to. THen, if the validation error is tripped, you can see data is present in each field of that record and this may provide a clue as to why you are getting an error.

                 If you have FileMaker Advanced, you might also try using the script debugger and data viewer to step through the script to spot where exactly you ge the validation error. IF you don't have advanced, you can add a few show custom dialog steps with different messages and then run the script to better narrow down where in the script this validation error is tripped.

            • 3. Re: Scripting error: field not on layout, but set anyway?
              lordhellfire

                   I had a similar issue and found the problem, at least what it was in my database:
              http://forums.filemaker.com/comment/291300

                    

                   Basically check that the next auto assigned ID in the portal ID record is higher than the record with the highest ID number.

                   The error is thrown because an ID is assigned that already exists, which causes a validation error if you have "Unique" validation selected.

                   My error was caused when I imported data which contained higher ID's than the field was defined to assign as the next ID.


                   The problem is that the error text does not directly convey that it is the validation check which fails. In my case it was the "Unique" validation that failed.
                   The error text misdirects your attention, by stating that the field requires a value (making you think the ID is empty, when it is not) and that the field is not available on the layout (which in this case is irrelevant as the ID field is autogenerated).


                   What the error SHOULD say is: "The portal field "xxx::yyy_ID" failed validation as it is not Unique."
                   That would direct your attention to the actual error.

                   Just like Justin Close said...