4 Replies Latest reply on Dec 11, 2012 2:48 PM by linuxpad

    Change layout and pass primary key to other layouts

    linuxpad

      Title

      Change layout and pass primary key to other layouts

      Post

           I have a a layout called jsa that is pulling from the jsa table. I have another layout call lift and is pulling from the lift table.

           I have setup a primary key and FK between the 2 in the database.  (jsa_id = jsa_id_sub)

           My issue is that when I switch from one layout to the next, the layouts are not passing the PK to the FK..  So the data is not related..

           I have looked for how to do this and come up empty..  I believe I will have to use a script I just don't know how to do it..??

           Any help would be greatly appriciated..

           JP

        • 1. Re: Change layout and pass primary key to other layouts
          philmodjunk

               One option is to place a portal to LIft on your jsa layout. With such a portal, you will only see related records and you can create new records and they will automatically be linked to the current jsa record.

               You can also use Go To Related Records from the jsa layout to pull up a found set of related lift records.

               If you need more, such as having new records created on the lift layout automatically be linked to the jsa layout, that can also be done via script and global variable--with an auto-enter calculation that enters the contents of the global variable into the fk field in lifts.

          • 2. Re: Change layout and pass primary key to other layouts
            linuxpad

                 Phil-

                 Thanks for the quick reply..  I am looking to do the 2nd option..  I portal view will not do in this case.  

                 I am  having issues with checkin to see if the record exist before creating one..  I only want a one to one relationship here..

                 I was trying something like this...

                 set variable [$jas_id:jsa_form::jsa_id]

                 go to layout ["Lift" (Lift)]

                 go to related record ??

                 if [isempty (lift:jsa_id_sub)]

                 new record / request

                 set field (lift)::jsa_id_sub[$jsa_id]]

                 end if

                  

                 ?? 

            • 3. Re: Change layout and pass primary key to other layouts
              philmodjunk

                   Try it this way:

                   if [isempty (lift:jsa_id_sub)]
                      set variable [$jas_id:jsa_form::jsa_id]
                      Go to Layout ["Lift" (Lift)]
                      New Record/Request
                      set field [lift::jsa_id_sub ;$jsa_id]
                   Else
                      Go To Related Record [Show only related records; From table: Lift; Using layout: "Lift" (Lift)]
                   End IF

                   Please note the changes I made in the red script step as compared to what you used in your set field step. That extra pair of [] you had indicates that you were putting the variable name in the wrong place.

                   When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.
                     

              • 4. Re: Change layout and pass primary key to other layouts
                linuxpad

                     That seems to be working.. thanks again for all your help.