7 Replies Latest reply on Jul 14, 2014 9:03 AM by philmodjunk

    calculated table name to go to particular record

    AliSheikh

      Title

      calculated table name to go to particular record

      Post

           Hello,

                I have a main layout ( sort of a dashboard ) where clients can scroll through records. From there, each user can go to other layouts which are based on duplicates of the dashboard layout's table. 

            

           What i'm trying to achieve is when is user navigates to other layouts from the dashboard i want them to view the same record that they were viewing on the dash on the rest of the layouts. Right now i have a script that grabs the layout name from the script parameter, but im not able to guide it to the same record in each instance of the layout.

            

           I could base the rest of the layouts off of the main table as the dashboard but i want to avoid doing that at the moment and see if there is a calculation that perhaps can be implemented in the same script which grabs the layout name from the parameter.

            

           please help, and thanks!  

        • 1. Re: calculated table name to go to particular record
          j.hall

               I think what you need to do here is Go To Related Record, using Layout Name by Calculation. You get this from the drop down "Show Record Using Layout" on the Go to Related Records Options Window. And then using your calculated name as your variable. This should give you the result you need.

          • 2. Re: calculated table name to go to particular record
            AliSheikh

                 Doesn't work that way. the tables are not related in the graph. But thanks for recommending. Anything else i can try?

            • 3. Re: calculated table name to go to particular record
              philmodjunk

                   But they can be related that way. Go to Related Record can specify one table occurrence as it's table setting in order to produce the desired found set, but then can specify any layout based on any occurrence of the same table in which to display that found set.

                   And if your layout's table occurrence is specified as "TableA" and a duplicate table occurrence is named "TableA2",

                   This GTRR:

                   Go To Related Record [Show only related records; From table: TableA; Using layout: "TableA2" (TableA2) ]

                   will replicate the found set on your Dashboard layout on the "TableA2" layout with the same record selected as the current record.

                   You can also perform a scripted find to find the record or records on layout 2 to match the record or records on your Dashboard layout. See this thread for scripted find examples: Scripted Find Examples

              • 4. Re: calculated table name to go to particular record
                AliSheikh

                     I tried that, if i use GTRR in the script  and use $target ( layout name variable using getscriptparameter) in the layout by name calculation, it gives the message " the operation could not be complete because its not part of related table ". 

                      

                     When i just use " go to layout " and set $target as calc then it navigates then. :S 

                      

                     thanks for helping, any other tips?

                      

                     Phil i'm going through the link right now , at the same time i wanted to ask if there is any way to use the layoutname from the script parameter in a calculation such as this for example :

                      

                     $target::fielda =$target::fieldb?

                      

                     I know that calc is wrong coz i've tried it, but is there something along those lines that exists in FM ?

                • 5. Re: calculated table name to go to particular record
                  philmodjunk

                       You cannot use a variable in GTRR. But there are alternatives, such as a series of If -Else -IF steps that use a different GTRR step for each specified layout target.

                       You can use it in a scripted find.

                       

                            Phil i'm going through the link right now , at the same time i wanted to ask if there is any way to use the layoutname from the script parameter in a calculation such as this for example:  $target::fielda =$target::fieldb?

                       Sorry, but I'm not sure how you intend to use that. Best guesses follow:

                       Go to Layout has a "layout name by calculation" option, you if your layout name is passed as a script parameter, you can use Get ( ScriptParameter ) inside that go to Layout option to go to a specified layout.

                       And a scripted find using set field steps to build the needed find requests can use set field by name to refer to a field using a table occurrence name passed as a script parameter.

                       And a single script parameter string can pass multiple values to a script, such as the name of a layout and the name of a table occurrence on which the layout is based--so your table occurrence name and layout name need not be identical.

                       Note: When passing layout names, table occurrence names, and/or field names as script parameters like this, you can very easily come up with a "brittle" solution where renaming layout, table, table occurrence or field causes scripts to fail as the names enclosed in quoted text will not update to match if you make such a design change. You can pass table occurrence names in parameters using the GetFieldName function and then you are not using this data enclosed in quotes and it will update should you later implement a name change. Layout names don't have as convenient a tool for that, but you might choose to pass the layout number instead of the name--though this then requires that you not re-order your layouts in Manage | Layouts or you can still break your script.

                  • 6. Re: calculated table name to go to particular record
                    AliSheikh

                         Thanks for the info Phil,

                          

                         Could you give me an example to this comment of yours:

                          

                         "And a scripted find using set field steps to build the needed find requests can use set field by name to refer to a field using a table occurrence name passed as a script parameter."

                         Just an example on how to pass a table occurence name in a find request"

                          

                         Thanks

                          

                    • 7. Re: calculated table name to go to particular record
                      philmodjunk

                           Let's say that your Dashboard layout is based on an occurrence named "Dashboard", the target layout is named "CustomerSales" and the table occurrence on which it is based is called "TableA1". And your primary key field might be named __pkSalesID.

                           I'm deliberately using different names for layout and table occurrence here in order to show a complete example.

                           Then you might use this script parameter expression:

                           List ( "CustomerSales" ; GetFieldName ( TableA1::__pkSalesID ) ; Dashboard::__pkSalesID ]

                           In your script,

                           Go to Layout [ GetValue ( Get ( ScriptParameter ) ; 1 ) ]

                           will go to the target layout.

                           Enter find mode[] ---> clear the pause step
                           Set Field By Name [ GetValue ( Get ( ScriptParameter ) ; 2 ) ; GetValue ( Get ( ScriptParameter ) ; 3 ) ]
                           Perform Script []

                           Will produce a found set of a single record--the record that was the current record on your dashboard when this script was performed.

                           Each of these functions can be looked up in FileMaker Help if they are unfamiliar.