6 Replies Latest reply on May 15, 2017 5:55 PM by Philip_Jaffe

    When entering Find Mode, AE calc in related table fires?

    justinc

      I noticed an odd issue recently with an auto-enter calculation that I have on a field.

       

      I'm using FMPA 15.03 on a file hosted on FMS 15.01.

       

      The general structure that is relevant here has two tables:       Projects, ProjectMembers

      Related by:     Projects::ID = ProjectMembers::ProjectID_fk

       

      A "Project" can have many different "ProjectMembers".  There's a field - "ProjectMembers::Sort_cont" - that has the auto-enter calc that appears to be the problem I am wondering about.  This field is part of a drag-and-drop feature, and so it has a number of global variables that are defined in this AE calc.

       

      The problem that I have noticed is that when this file opens, it runs through a Startup script that, of course, initializes a few fields, etc.  During this Startup process, it goes to a layout based on the 'Projects' table and does a Find for all 'active' Projects.  The odd part is that when it does this Find, as soon as it enter's Find Mode, the AE calc on the related "ProjectMembers" is somehow firing - and it sets all these global variables (7 of them).

       

      The variables aren't a problem, really - except from the standpoint of clutter.  I don't want them to be set at this stage.  Here are the steps from the Startup script where the problem occurs:

       

      Go To Layout ["Script Use Projects"] (Projects)

      ...

      Set Error Capture (On)

      Enter Find Mode (pause: off)

      Set field [ Projects::Active = 1 ]

      New Record

      Omit record

      set field [ Projects::List = 1 ]

      Perform Find

       

      The g-vars get set when it runs the 'Enter Find Mode' step.  This layout has nothing on it - no fields, no layout objects, nothing.  After it enters Find Mode, the Data Viewer doesn't even report that it's in an active field ("get(activefieldname)" is empty).  And yet it has processed this AE calc in this related table/record(s).

       

      So...how is this AE calc getting triggered?  I'm guessing that it is part of some pre-fetch/caching process.  This appears to be one of those oddities about FM that I don't have a solid grasp of yet - how it pre-fetches related tables/records/data.  Which is frustrating because, as in this case, it appears to trigger calculations and data transfers that could slow the system down.  It really shouldn't be triggering this calculation at all, I would say.

       

      And it's a container field - this would imply to me that it has not only transferred this related record (probably many - however many might be related to this "Project" record), but it has downloaded this related-record's container field data.  In this case the container holds only a small amount of data, but what if I had large images stored in container(s) on this related record?  Is it downloading all of that, too?  (As far as I am aware, FM tries to be smart and NOT download container data unless it is actually rendered - but that doesn't appear to be the case here.  Unless the AE calc is somehow separated from the data in the container-contents.)

       

      Thanks,

      Justin

        • 1. Re: When entering Find Mode, AE calc in related table fires?
          philmodjunk

          Can you post the auto-enter calculation? Are you sure that it's not a calculation field instead?

           

          This layout has nothing on it - no fields, no layout objects, nothing.  After it enters Find Mode, the Data Viewer doesn't even report that it's in an active field ("get(activefieldname)" is empty).  And yet it has processed this AE calc in this related table/record(s).

          What is or is not on the layout, which layout field is active (has the focus) will have no bearing on how this calculation evaluates.

          • 2. Re: When entering Find Mode, AE calc in related table fires?
            justinc

            Yes, it is not a calculation field:

            Sort container field.png

             

             

            Here's the AE calc (originally written by Charles Delfs; edited here for brevity):

             

            Let([

                $$DragSort_TargetRowNumber = Get (RecordNumber)

                ; $$DragSort_ContainerTableName = Get (ActiveFieldTableName)

                ; $$DragSort_PrimaryIDField = GetFieldName ( __id__n )

                ; $$DragSort_SortFieldName = GetFieldName ( Sort_CustomIndex )

                ; $$DragSort_StatusIDFieldName = GetFieldName ( Status_fk )

                ; $$DragSort_TargetSortPos = Sort_CustomIndex

                ; $$DragSort_TargetSortBefore = GetNthRecord(ProjectMembers::Sort_CustomIndex; Get(RecordNumber) - 1 )    

                ; $$DragSort_TargetSortAfter = GetNthRecord(ProjectMembers::Sort_CustomIndex; Get(RecordNumber) + 1 )

                ; $$DragSort_TargetID = GetField ( $$DragSortPrimaryIDField )

                ; ~image = Base64Decode (<base64 code here>; "blank.png" )

             

            ];

                Case(

                    Self = "";

                    ~image; // on record creation we need a value, but FMP quirk stops this from evaluating on drop so we eval 'self'

                    ~image

                )

            )

             

            • 3. Re: When entering Find Mode, AE calc in related table fires?
              philmodjunk

              I cannot replicate that using WIndows 10, and FileMaker 15.

               

              I defined a pair of fields, one text, one container. I gave each simple expressions that used let to assign values to global variables followed by a case function. Each field creates a different global variable.

               

              Once I used a watch expression with Let to destroy the variables--as they were created by the initial creation of a record in the file's table, I could enter find mode and the global variables were not created.

              • 4. Re: When entering Find Mode, AE calc in related table fires?
                DavidJondreau

                And there are no triggered scripts on the layout?

                How do you know this happens right when you enter Find mode?

                • 5. Re: When entering Find Mode, AE calc in related table fires?
                  justinc

                  No script triggers on the layout.

                   

                  I stepped through it using the debugger; when the step pointer is at the line "Enter Find Mode", the variables don't exist; at the very next step in the script , after executing 'enter find mode', the variables are showing up in my Data Viewer.  I guess I haven't tried skipping that step to see what happens.

                  • 6. Re: When entering Find Mode, AE calc in related table fires?
                    Philip_Jaffe

                    I am not sure I fully understand WHY, but this reminds me of a thread we were discussing a while back involving SetField and auto-enter.  Could this be related to what's going on with justinc's question?

                     

                    Housekeeping field for IP address