4 Replies Latest reply on Apr 5, 2017 10:12 AM by philmodjunk

    Insert Current Date ... not working all the time

    ctmorrison2105

      We're seeing an issue (FileMaker 15 Go) in which the Insert Current Date() function is not working all the time.  This only surfaced after we updated all of the iPads to the current iOS and put them all on FMG 15.  At the same time, we moved our FileMaker database to a FileMaker 15 server.  Is any one else seeing intermittent functionality of this function?  It's being called in a script that also calls Insert Current Time() and it appears to function just fine.

        • 1. Re: Insert Current Date ... not working all the time
          Magnus Fransson

          Hi ctmorrison2105,

           

          All the "Insert..." script steps are depending on that the field is present on the current layout. Thus they are very fragile. A much better option is to use the script step "Set Field" in conjunction with the function "Get(CurrentDate)". It will perform much more stable.

           

          With best regards Magnus Fransson.

          • 2. Re: Insert Current Date ... not working all the time
            philmodjunk

            If you click Home here, you can find a specific section for reporting an issue such as this as it may be a bug.

             

            But I would never use Insert Current Time nor Insert Current Date unless I had a compelling reason to do so. Much better to use Set Field with the appropriate get function to get the current date or time.

             

            Steps that start with "insert" will fail if the specified target field is not present on the current layout. If you don't specify a target field, the step will fail if the focus is not in a field at the time the step is executed. Insert steps also trip script triggers as they change focus on the layout when they execute.

             

            Set Field does not have those limitations and thus is less "brittle". (Less likely to "break" do to future design changes such as removing a field from a layout or adding a script trigger.)

            • 3. Re: Insert Current Date ... not working all the time
              ctmorrison2105

              OK...I appreciate the feedback.  The field is on the layout and has been for about 3 years.  We've never seen this issue in the past and this layout and button activated script gets used hundreds of times a day.  I will likely change the script to utilize the Set Field function due to the recommendations here.  Thanks for the quick responses!

              • 4. Re: Insert Current Date ... not working all the time
                philmodjunk

                Please note that removing the field is not the only way that a layout change can affect the successful execution of a script that uses an "insert" script step. Adding a script trigger to the layout might also create an issue--and this might be an issue only part of the time as you report here.

                 

                Consider this hypothetical pair of scenarios:

                 

                You have three fields: Name, Address and Date. You use an Insert step to insert a date into the Date field. Prior to performing the script, the cursor is setting in the address field. You run the script and all works correctly. The next time, the cursor is in the Name field, you run the script and it fails.

                 

                The difference could be an OnObjectExit, OnObjectSave or OnObjectValidate trigger set on the name field. The Insert step puts the focus into the Date field and this trips any of the above three triggers--performing that script right in the middle of your script that's doing the insert.

                 

                Another subtlety that can be a factor is if you have enabled set error capture prior to this in your script. A Field validation error might keep things from working, but set error capture has kept the validation error message from appearing and thus your user only knows that the data did not appear in the field as expected.

                 

                But if you have confirmed that none of these issues are at fault here, PLEASE, post an issue report to bring it to the attention of FileMaker Tech Support staff.

                1 of 1 people found this helpful