7 Replies Latest reply on Jun 17, 2014 2:07 AM by Mike_Mitchell

    Relationship not "working" when file is hosted

    davehob

      I’m working on a room booking application, with sessions (SSN), resource bookings (RBK) and resources (RSC). This is a data-separated application, on FM13.

      In the sessions table (in the DATA file), I have a calc field “resourcesAvailable”, which lists the keys of available resources. It’s defined thus:

      Let ( [
      ~allResources = List (SSN_RSC~all::id);
      ~bookedResources = List (SSN_SSN_RBK_RSC~allNow::id)
      ];
      FilterList ( ~allResources; "NotEquals" ; ~bookedResources ; 0 )
      )

      (So, basically, if a resource isn’t in the list of booked resources, it’s available. FilterList is a tried and tested CF, not of my making.)

      It works fine, on the local machine. But I’ve uploaded a test version of the application to a remote host, and, when I first run it, the calc field is not correctly populated. This is because there’s a problem with the relationship, SSN_SSN_RBK_RSC~allNow, via which we should see the ids of all resources booked for all or part of the same time slot, but, in the remotely hosted setup, it shows nothing, so ALL resources are regarded as available.

      Obviously this is a major problem, as it could lead to double bookings.

      Once this part of the system has been (i.e. added or deleted a resource booking to/from a session), it’s fine – only unbooked resources are listed. So I’m thinking maybe it’s just a missing Commit of Refresh somewhere, but I’m a rather confused by the whole thing.

      So the question is, why is that relationship behaving differently in the hosted environment from the local environment? And what do I have to do to make this crucial part of the application behave as I need it to? And, more important, what have I not understood about the difference between the local and hosted environments?

      Any help, as ever, much appreciated.

      Dave.

        • 1. Re: Relationship not "working" when file is hosted
          Mike_Mitchell

          Hi, Dave.

           

          I can't really say for certain (not having seen the setup), but I can think of a couple of possibilities off the top of my head:

           

          1) Could be a caching issue with the Relationships Graph.

           

          2) Could be a difference in the way one of the calculations used by the CF evaluates on the client vs. on the server.

           

          It's possible that all the necessary stuff is being evaluated from the server side, but hasn't yet been downloaded to the client until you perform some action that causes it to. Just a thought.

           

          Another possibility is that you have an unstored calculation lag. You might need to force a window refresh to trigger an update of something in a dependency chain somewhere to get the correct values.

           

          Mike

          • 2. Re: Relationship not "working" when file is hosted
            wsvp

            Another possibility to check, if you have any Global Fields establishing relationships.  When run locally Globals will hold the last value set, when run on FM Server this could break the relationship if the value is not reset.

            • 3. Re: Relationship not "working" when file is hosted
              wimdecorte

              As an aside; this does not sound like the kind of thing you'd want to calculate through a calculated field, but rather in a script where it is relevant.

              That also makes troubleshooting a lot easier.

              • 4. Re: Relationship not "working" when file is hosted
                davehob

                Mike thanks for these suggestions.  It strikes me that all of these possible problems would be resolved by Wim's suggestion of changing my approach entirely, and using a script to check for available resources when the occasion arises.  But re. your first suggestion, that it may be a caching issue with the Relationships Graph, that sounds as though it may have implications elsewhere, so do you have any suggestions as to how to prevent/avoid this? 

                 

                Thanks again,

                 

                Dave. 

                • 5. Re: Relationship not "working" when file is hosted
                  davehob

                  Thanks - no globals involved this time, but I appreciate the reminder.

                  • 6. Re: Relationship not "working" when file is hosted
                    davehob

                    Wim,

                     

                    I've used an unstored calc here because that's what was handed down in the previous version of the application.  I think the rationale was to have the list of available resources "always up to date", but I think you're right - it would be better to have this as a plain text field, which is updated when showing a SSN record (the layout includes a portal of available resources, i.e. the contents of this field), and when adding or deleting a reource to/from a session.  As well as being more reliable, this would have the added advantage of getting rid of an unstored calc, which is bound to bring performance improvement, isn't it?

                     

                    So thanks for the aside!

                     

                    Dave.

                    • 7. Re: Relationship not "working" when file is hosted
                      Mike_Mitchell

                      Most likely, you'd need to do something that would force a refresh of the calculation in question. I'm assuming this calculation is in the data file, so it doesn't need to cache to the client until it's needed there. So go to a layout in the data file and perform a window refresh.

                       

                      Again, it's just a guess. I think it's more likely that it's a dependency / unstored calc issue.