2 Replies Latest reply on Sep 21, 2012 9:18 AM by JorgeFernandez

    Autodetect layout

    JorgeFernandez

      Title

      Autodetect layout

      Post

           Hi!! As many times I need some help...

           I´m trying to set a layout setup based on desktop or laptop use.

           I created an initial screen with 2 buttons; desktop and laptop using this scripts

           For Desktop

           Set Field [System::Var; 1]

           Go to Layout ["Main" (table)]

           For Laptop

            

           Set Field [System::Var; 2]

           Go to Layout ["Portable" (table)]

           Where System is just a table with just one record to use as a variable, Main is the layout design for desktop and Portable is the layout design for laptop

            

           The issue begins here, working on lists layouts, trying to go to a selected record and creating a script like this:

           If [System::Var = 1]

                Go to Related Record [Show only related records; From table: "table";  Using layout: "Main" (table)]

           Else 

                Go to Related Record [Show only related records; From table: "table";  Using layout: "Portable" (table)]

           End If

            

           And this is not working, but can´t find the way.

            

           Need some help.

           Thank you

        • 1. Re: Autodetect layout
          philmodjunk

               If System::Var is not a field with global storage, the value in the field may not be accessible from every layout in your file. Whether or not it is depends on any relationships you have defined linking it to the layout that is current at the time your script is performed. Also, if it is not a global field and you have more than one user accessing the database at the same time, the data from one user will replace that of the other.

               Instead of adding a bunch of relationships between System and your other tables, make Var a field with global storage or use a $$GlobalVariable instead of a field to hold this value. Either a global field or a global variable will hold data specific to each user so this also solves the issues that can occur when you have more than one user connected to your database at the same time.

          • 2. Re: Autodetect layout
            JorgeFernandez

                 Lets see...

                 the first two buttons I wrote this:

                 Desktop

                 Set Variable [$$System; Value:1]

                 Go to Layout ["Main" (table)]

                 Laptop

                  

                 Set Variable [$$System; Value:2]

                 Go to Layout ["Portable" (table)]

                  

                 And for the script on the list:

                  

                 If [$$System = 1]

                      Go to Related Record [Show only related records; From table: "table";  Using layout: "Main" (table)]

                 Else 

                      Go to Related Record [Show only related records; From table: "table";  Using layout: "Portable" (table)]

                 End If

                  

                 Now everything is working like a charm.

                  

                 Thanks!!