1 2 Previous Next 17 Replies Latest reply on Jul 17, 2014 6:09 AM by DavidJondreau

    Sending Messages Between Users - Pro 13

    paulwatts

      Hi

      I have 4 users sharing a file hosted on one of the user devices.

      I want a remote user to be able to send a standard message to one or more other users as an alert.

       

      I have read previous dialogue on this issue and accept that this will involve the use of the "Install Ontimer Script". I have configured the following:-

       

      1. There are 2 buttons on a "Utilities" layout. The 1st button starts a timer in the open window (interval = 5 secs and a global variable [GV] is set to "0") whilst the 2nd button stops the same timer.

       

      2. Using these buttons, each user either starts the timer in his/her window if he/she wants to receive messages or stops the timer if not.

       

      3. The message sender clicks a "Send Message" button initiating a script that sets GV to "1".

       

      4. The timer then initiates a script "Show Custom Dialogue" conditional upon GV being "1".

       

      5. The message box has an "OK" button that closes the message and resets GV to "0".

       

      My expectation was that each user that has their own timer running will receive the message and that the 1st user to click "OK" will reset the GV to "0". This doesn't happen in practice. The message only shows on the message sender's device.

       

      Is the problem with the global variable? In particular:-

       

      Q1. Is it true that the Global Variable will only operate on the device on which it is created and not throughout the shared file (I have read that the Global variable is stored in RAM not on the hard drive)? If this is the case, can anyone suggest what else will work?

       

      Q2. Is it ok to change the value of the Global Variable using a Set Variable step in a script? I assume that a variable can be varied but this is not obviously true according to the stuff that I have read.

       

      Best wishes

       

      Paul

        • 1. Re: Sending Messages Between Users - Pro 13
          taylorsharpe

          Q1:  Global variables are local only and their data is not shared with any other user.  Created a stored field somewhere.  That is what gets around it.  Many people run into this issue when setting preferences or user choices in a system.  They often have a preference table that always has a single record that they store fields.  The fields that need used by a single user are globally stored and those that need shared are stored as a regular stored field.  You just have to watch out for record locking issues in regards to stored fields.  Or you could have a table that creates a new record for each user's session and it might also be useful a form of an audit log of who is using the database. 

           

          Q2:  The Set Variable script step is the only way you can change a Global Variable.  Just use the $$ prefix to make the variable a global in the Set Variable. 

          • 2. Re: Sending Messages Between Users - Pro 13
            steve_ssh

            Perhaps not so relevant to Paul's originally posted objective, but rather a small point to clarify concerning setting global variables:

             

             

            Q2:  The Set Variable script step is the only way you can change a Global Variable.  Just use the $$ prefix to make the variable a global in the Set Variable. 

             

             

            Another possible way to set the value of a global variable is to assign its value using a statement within a Let() function call.  This can be leveraged anywhere that the calculation engine is invoked.

             

            I would venture to say that this is a less common means of updating a global variable than the Set Variable script step, and I believe that it can lend itself to writing code which is more difficult for others to debug.

             

            Nonetheless, I consider it a valid technique to have in an FM development toolkit -- one which is both useful and appropriate in certain scenarios.

             

             

            Best,

             

            -steve

            • 3. Re: Sending Messages Between Users - Pro 13
              taylorsharpe

              Good point Steve.  I occasionally do that and its a nice way to create variables while creating lets.  I guess I need to be careful about using the word "only" <grin>.  Cheers!

              • 4. Re: Sending Messages Between Users - Pro 13
                paulwatts

                Hi taylorsharp.

                Thanks very much for your input.

                I must say that I was hoping for a different answer. It seems odd to me that a "global" variable is only available to one user and that there is no provision for a variable that all users have access to. Bewildering, actually!!

                I tried using a regular field in a dedicated table before using the global variable but the overall message receiving function appeared to be dependent on which layout the user had open at the time. Maybe I made a mistake. I'll try it again.

                 

                Paul

                • 5. Re: Sending Messages Between Users - Pro 13
                  paulwatts

                  Hi Steve.

                  Thanks for this additional comment.

                   

                  Paul

                  • 6. Re: Sending Messages Between Users - Pro 13
                    Mike_Mitchell

                    Paul -

                     

                    A "global" variable is somewhat analagous to a global field. While its value is held across the entire solution (until reset), each user has his own value. So they're session-specific. (The same is true of local variables; the difference is that a local variable only survives until the end of the script.)

                     

                    HTH

                     

                    Mike

                    • 7. Re: Sending Messages Between Users - Pro 13
                      paulwatts

                      Thanks Mike.

                      I presume that the value in a global field is seen by all users.

                       

                      Paul

                      • 8. Re: Sending Messages Between Users - Pro 13
                        Mike_Mitchell

                        No, a global field is seen only by the current user. Each user gets his own values.

                        • 9. Re: Sending Messages Between Users - Pro 13
                          paulwatts

                          Mike.

                          When is a field a global field?

                          Is it when global storage is selected for a field?

                           

                          Paul

                          • 10. Re: Sending Messages Between Users - Pro 13
                            Mike_Mitchell

                            Yes, that's correct.

                            • 11. Re: Sending Messages Between Users - Pro 13
                              paulwatts

                              Hi Taylor.

                              I have created a regular field in a dedicated table as a message status indicator (MSI). The default value of this field is 0.

                              I have also created a relationship between this table and the (message sender's) layout/table which holds the send button which changes the MSI value to 1.

                               

                              When the button is clicked, the value of MSI changes to 1 (I have checked that this works). The timer then executes a Show Custom Dialogue script if MSI=1. The problem now is that the (Show Custom Dialogue - standard message) message appears but only if the message receiver's current layout is the one holding the send button. I need it to appear irrespective of which layout is currently open.

                               

                              Any ideas?

                               

                              (Please ignore my earlier reply, which I have withdrawn, suggesting that I have fixed the problem).

                               

                              Paul

                              • 12. Re: Sending Messages Between Users - Pro 13
                                SecretWeaponLabs

                                I would just get seedcode fmchat for your purposes if you haven't doen much coding yet.

                                 

                                http://www.seedcode.com/fmchat/

                                • 13. Re: Sending Messages Between Users - Pro 13
                                  mdenyse

                                  Hi Paul,

                                   

                                  I built a no-frills messaging system for a client. They have many concurrent users sending messages to individuals (or broadcast to ‘all’). The messages can fly fast and furious, so here’s what I did:

                                   

                                  1. Create a table to store each message sent as it’s own record (from, to, message, etc.).

                                   

                                  2. Have a ‘User’ table (which keeps track of lots of other things) with a field for storing the primary key of the last message record it viewed. This could also be a global if you don’t need persistence across sessions. At login the value is set to the highest primary key in the message table so the user is not flooded with new ‘old’ messages (you may or may not want this depending on the importance of messages you’re sending).

                                   

                                  3. Use Install OnTimer Script[] to run a script every X seconds. It checks if there are any message records whose primary key is higher than the user’s last viewed message ID. In my case, we launched non-modal windows to display the message (so they could receive many at once and also reply to each individually at will). After opening the windows it updates the user’s last view message ID.

                                   

                                  That’s really all there is to it. If you don't need to keep the messages around, just set up a nightly script to delete old messages.

                                   

                                  Mark

                                  • 14. Re: Sending Messages Between Users - Pro 13
                                    paulwatts

                                    Hi Mark.

                                    I really appreciate your input to this subject. Thanks. I may well use your idea in the future if we develop a need to use frequent and variable messages. Just now, however, all I need is to show a single pre-written message (which says, in effect, that a remote user has made an input of data on a specific layout and other users should look at this data on this same layout asap and should react accordingly - it's an alert!!). I need the message/alert to show up on all user screens as soon as it is sent.

                                     

                                    I currently use a Custom Dialogue box which works so long as users are currently using certain layouts but it doesn't work if users are using other layouts. I thought it might be to do with relationships but haven't yet found a solution that works.

                                     

                                    What is a Non-modal Window? Might this be the key to fixing my problem?

                                     

                                    Paul

                                    1 2 Previous Next