10 Replies Latest reply on Jan 7, 2009 7:59 AM by johnhorner

    calculating portal row number and navigating to related records

    johnhorner

      Title

      calculating portal row number and navigating to related records

      Post

      hi,

       

      i have a portal that typically displays about 6 related records (timesheets for various individuals).  i have it set up now so that if i click a button in one of the portal rows i go to a different layout that finds the originally clicked record, as well as all the other records for the individual for the current year.  however, more often than not, the record i clicked in the original file is not the first or last portal row, nor is it the first or last record for that individual.  is there any way to calculate the number of the portal row (e.g. 3 out of 6) that was clicked so that when i get to the new layout and the correct set of found records, i can go to that specific (e.g. 3rd) record rather than just the first or last record?  any thoughs would be much appreciated.

       

      thanks,

       

      john h.

        • 1. Re: calculating portal row number and navigating to related records
          Jens Teich
             You are looking for the script step 'Go To Related Record'.

          Jens
          • 2. Re: calculating portal row number and navigating to related records
            ninja
              

            Jens is most correct.  We have an inventory dbase that I use this feature on constantly.

             

            Put a button in the portal row (as you describe doing)...

            Tie it to a script...

            The script need only be one step - "Go to Related Record"

            within GTRR, define the layout you want to view the related record with.  Get fancier if it fits the situation and have it form a found set made of all related records, but actually show the one you clicked, etc...all of these are part of the GTRR details and options when writing the script.

             

            Just to break a thought process if it's in the way...you do not need to know the portal row number in order to do this.  The GTRR step will not say "go to record number such and such", it will instead say "go here" and simply point through the portal.

             

            Have a great day!

            • 3. Re: calculating portal row number and navigating to related records
              johnhorner
                

              hi jens,

               

              i think you helped me with a solution the other day.  thanks again by the way.

               

              anyway, i actually saw this script  step and inteded to use it but i don't see any way that i can specify which record i want to go to.  the portal i am starting from shows all "paid" timesheets so there are several different individuals displayed by this relationship as well as timesheets from more than one year.  so when i tried using "go to  related record" it correctly displays the record i want in a new window and layout, but it finds all unpaid records (as defined by the relationship governing the portal).  if i then add a couple of script steps to constrain the found set to the particular payee i am interested in, it then displays the first record in the newly constrained set.  so my problem is to get back to displaying this one particular record i clicked on originally and which is now somewhere in the middle of the found set.  i was going to use a "go to record/request/page" script step and using a calculation to point to the specific record, but then i still have the original problem of setting up a calculation to determine which record it is that i want out of the found set.  i am probaly not explaining this very well.... does this make sense?

               

              thanks for your help.

               

              john h.

              • 4. Re: calculating portal row number and navigating to related records
                johnhorner
                  

                hi ninja,

                 

                thanks for you reply.  i just wrote back to jens (who had responded just before you) to explain a little more clearly my issue.  it is a little more complicated than just using the one go to related record step because i am not just trying to see this one particular record within all of the related records, but rather within a subset that i define using a couple of constrain find set steps.  please read my reply to jens to get a more complete explanation of my dilemma if you think you might have a solution.  thanks for your help so far.  i appreciate it.

                 

                john h.

                • 5. Re: calculating portal row number and navigating to related records
                  Jens Teich
                     Think of a portal showing only the selected records. Which relationship do you need?

                  Use exactly this relationship with the GTRR script step to select exactly the checked portal rows.

                  Jens

                  • 6. Re: calculating portal row number and navigating to related records
                    johnhorner
                      

                    hey jens,

                     

                    thanks for the reply.  sorry to keep bothering you with this.  i have been wrestling with it for a while.  i have a feeling that i cannot set it up the way i want to.  i want to have a portal which shows all "paid" timesheets (multiple payees, multiple years) which is not a problem... that is all set.  but from within that portal i want to be able to click on a record and, in a new window and layout, show paid records that are only for that individual and only for that specific year.  all of the relationships that use this as the criteria find the correct set of records but still won't show the original record in the new window as the current/active record.  i still need to find a way to get it to navigate to that specific record within the found set.  in attempting to set up the appropriate relationship do you know if it should be between the table from which the portal records which contain the button are displayed, or the main table for the layout as a whole on which the portal resides?  i have tried both but still no luck with getting directed to the specific record.  thanks for the thoughts so far.  if i can't figure it out i'll just make a simpler construction with the relationship i need as you suggested.  i think i will also try to figure out a scripting routine to count the position of the specific record within the found set and then use that number in the go to related record step.

                     

                    thanks again,

                     

                    john h.

                    • 7. Re: calculating portal row number and navigating to related records
                      Jens Teich
                         You want to see paid records of a specific year. To show all paid ones you need a relationship like

                      const_paid = pay_status

                      Where left side is a constant "paid" or 1 and pay status is the matching status. This is easy. Now you click on one of these portal rows and want to see only that year. The chosen year should be kept in a global g_year so that you can introduce a second condition into the relationship definition

                      g_year = year

                      The value of g_year is set with the script that runs when the button is clicked.

                      Jens




                      • 8. Re: calculating portal row number and navigating to related records
                        ninja
                          

                        Good morning John,

                         

                        I know Jens has been working with you, so if I'm butting in...feel free to tell me to butt out.

                         

                        From your descriptions, it seems that you can already get everything you want, exactly the way you want it, except for that last piece which is to go to the record you originally clicked on.  It seems like you've already tackled the new layout, the constraint of the found set to exactly what you want, and now you just want to go to a particular record within this new window, within it's found set, and look at that record first as the active record.

                         

                        If this is the case, why not tag the record in question at the outset of running the script.  Before you GTRR, do a Setfield within the portal record. 

                         

                        - Create a field in your invoice table called "FindMe" and leave it blank for all records.

                        - Make the first step of your script "SetField[Invoices::FindMe;"Me"]

                        - Then run your script the way you already have it working: GTRR, finding your set, constraining your found set...etc.

                        - And lastly Go to Record/Request/Page [Invoices::FindMe="Me"]

                        - and wrap up by setfield Invoices::FindMe="" to clear the marker.

                         

                        Is this what you're after?

                        • 9. Re: calculating portal row number and navigating to related records
                          johnhorner
                            

                          hi jens,

                           

                          thanks for your ongoing help in attempting to solve this problem.  i understand what you are saying, which is essentially the structure i arrived at yesterday but it was still not going to the specific record i wanted because the relationship in the first portal had to be"non-restrictive" (meaning that it had to include all paid records for every year and every payee).  so every relationship i tried in the manner you suggested using a global year and payment status still was giving me the correct set of records but not taking me to the specific one i wanted to see first.  please see the other attempted solution sent by "ninja"below which was exactly the type of thing i was hoping to accomplish although it turned out (at least as far as i can tell) that the go to record/request/page function does not operate as he had thought and was therefore not a soution in the end.   below is the solution that i came up with late last night that is now working as i had hoped!this is the script that runs when i click on the button in the portal displaying all paid records and it takes me to all of the records for that particular year and individual and then makes the record i clicked on the current or active record in the new window and layout.

                           

                          -----------------------------------

                           

                          Set Variable [$PayeeFullName; Value:time sheets_paid::payee full name]

                          Set Variable [$UniqueID; Value:time sheets_paid::time sheet unique id]

                          Set Variable [$PayYear; Value:time sheets_paid::payment year]

                          Go To Related Record [Show ony related records; From table: "time sheets_paid"; Using layout: "time sheets" (time sheets_all)]

                          Enter Find Mode[]

                          Set Field[time sheets_all::payee full name; $PayeeFullName]

                          Constrain Found Set[]

                          Set Variable [$TargetRecordNumber; Value:1]

                          Loop

                            Exit Loop If [time sheets_all::time sheet unique id=$UniqueID]

                            Go to Record/Request/Page [Next; Exit after last]

                            Set Variable [$TargetRecordNumber; Value:$TargetRecordNumber+1]

                          End Loop

                          Go to Record/Request/Page [No dialog; $targetRecordNumber]

                           

                           -----------------------

                           

                          thanks so much for all of your help.  it has been greatly appreciated!

                           

                          kind regards,

                           

                          john h.

                          • 10. Re: calculating portal row number and navigating to related records
                            johnhorner
                              

                            hi ninja,

                             

                            thank you for your input.  that is exactly the kind of thing i was looking for and when i first saw your solution i couldn't believe how simple and elegant it was.  however, i attempted to implement it and i discovered that the gtrr calculation requires result which is a number because, as far as i can see, it does not attempt to go to the record with the matching result, rather, it attempts to go to record # "Me" out of X records in the found set.  late last night i did come up with a solution which i got working.  once i arrived at my correct set of records i scripted a counting loop to find which record it was in the set and then used gtrr to navigate to it.  here is the whole script i used... it is a little cumbersome but at least it is working:

                             

                            -----------------------------------

                             

                            Set Variable [$PayeeFullName; Value:time sheets_paid::payee full name]

                            Set Variable [$UniqueID; Value:time sheets_paid::time sheet unique id]

                            Set Variable [$PayYear; Value:time sheets_paid::payment year]

                            Go To Related Record [Show ony related records; From table: "time sheets_paid"; Using layout: "time sheets" (time sheets_all)]

                            Enter Find Mode[]

                            Set Field[time sheets_all::payee full name; $PayeeFullName]

                            Constrain Found Set[]

                            Set Variable [$TargetRecordNumber; Value:1]

                            Loop

                              Exit Loop If [time sheets_all::time sheet unique id=$UniqueID]

                              Go to Record/Request/Page [Next; Exit after last]

                              Set Variable [$TargetRecordNumber; Value:$TargetRecordNumber+1]

                            End Loop

                            Go to Record/Request/Page [No dialog; $targetRecordNumber]

                             

                             -----------------------

                             

                            i'm sure there is a simpler/smarter solution but i am not smart enough to figure it out.  anyway, thanks so much for all the input.  it was hepful at finally arriving at a solution.

                             

                            kind regards,

                             

                            john h.