14 Replies Latest reply on May 12, 2015 11:53 AM by tays01s

    Portal sorting

    tays01s

      Title

      Portal sorting

      Post

      I want to sort alphabetically. However, I have several fields requiring input, so if sorting is done on the first field, product name, if low down the alphabet, it disappears off screen.

      I'd thought to instead have a script sort when exiting the object (portal), but it doesn't react.

        • 1. Re: Portal sorting
          nicolai

          Try script trigger on exit the field and save portal row in a variable, commit record and go to the saved portal row, move focus into the next field.

          • 2. Re: Portal sorting
            tays01s

            Thanks, I'd experimented with something similar. The odd thing is that when I 'move focus into the next field' [I take it you mean "Go to next field"] instead, focus moves to a 'random' field on another tab of the layout. According to 'Set Tab Order', the focus should have gone to the desired field. I've also attempted 'Go to field' and specified my desired next field. Result is that I again go to another tab on the layout, though it's not so clear which field is in focus.

            • 3. Re: Portal sorting
              nicolai

              One way to make sure you are going to the correct field is to give it an object name and then "Go to object" with the name specified. This way you will end up in the right field even if you place two different instances of the same field on the layout.

              To make sure you are on the right row, you will need to go into the field on this portal (this will get you into the first row) and then specify row with go to portal row.

              What you are getting is not standard behaviour, so you need to check if there are any script triggers already involved. Try to duplicate the layout and simplify it by removing extra tabs and portals. This should let you trace the problem

               

               

              • 4. Re: Portal sorting
                philmodjunk

                The problem is that the current portal row at the time you exit the portal row won't match the portal row the record changes to when the portal's specified sort order causes the records to update.

                An object name won't help this as the same field will have the same object name in every row of the portal.

                The only way that I can think of to scroll the portal record back into view would be a looping script that loops through the portal rows and stops when it reaches the correct record. Your script would save the uniqueID of the portal record in a variable, then commit records (if needed) to force the portal display to update and then loop throught the portal rows comparing unique ID's to the variable's value and exiting the loop when they match.

                • 5. Re: Portal sorting
                  nicolai

                  I have to agree with  PhilModJunk My answer did not take into account the fact that the row number will change. His latest solution looks like the best approach

                  • 6. Re: Portal sorting
                    tays01s

                    I've tried the follownig, but it gets stuck in a loop:

                    Commit Records/Requests [ No dialog ]

                    Go to Layout [ DrugsUsed” (DrugsUsed) ]

                    Go to Record/Request/Page [ Last ]
                    Set Variable [ $Portal_row; Value:DrugsUsed::__ID ]

                    Go to Layout [ Patient_L” (Patient) ]
                    Go to Object [ Object Name: "DrugsUsed_Loss" ]

                    Loop

                    Go to Portal Row [ DrugsUsed::__ID=$Portal_row ] [ No dialog ]

                    End Loop
                    Go to Field
                    [ DrugsUsed::rx_Aim ]

                    • 7. Re: Portal sorting
                      philmodjunk

                      Don't see why you are changing layouts. How is the new portal record created? By user data entry or a script?

                      The layout change, commit records. go to record [last] all reset the portal scroll bar and removes any focus on a particular portal row. So by the time you get to line 4, all three of the preceding script steps ensure that the value captured in your variable will be the ID number of the first record in your sorted portal. That won't be the correct record.

                      Your loop then lacks any step to exit the loop such as an Exit Loop If step nor does it have any step to change portal rows in order to search  down through them.

                      • 8. Re: Portal sorting
                        tays01s

                        Is this better? However, I still have the problem that the focus moves to a different tab. Possibly of interest, the portal fields have a 'tab order' of 158 to 161 & 163. The focus shifts to 162 on a different tab of the same layout.

                        Commit Records/Requests [ No dialog ]
                        Set Variable [ $Portal_row; Value:DrugsUsed::__ID ]

                        Loop

                        Go to Portal Row [ Select; Next ]
                        Exit Loop If [ DrugsUsed::__ID=$Portal_row ]

                        End Loop
                        Go to Field
                        [ DrugsUsed::rx_Aim ]

                        • 9. Re: Portal sorting
                          tays01s

                          Is this better? However, I still have the problem that the focus moves to a different tab. Possibly of interest, the portal fields have a 'tab order' of 158 to 161 & 163. The focus shifts to 162 on a different tab of the same layout.

                          Commit Records/Requests [ No dialog ]
                          Set Variable [ $Portal_row; Value:DrugsUsed::__ID ]

                          Loop

                          Go to Portal Row [ Select; Next ]
                          Exit Loop If [ DrugsUsed::__ID=$Portal_row ]

                          End Loop
                          Go to Field
                          [ DrugsUsed::rx_Aim ]

                          • 10. Re: Portal sorting
                            tays01s

                            Is this better? However, I still have the problem that the focus moves to a different tab. Possibly of interest, the portal fields have a 'tab order' of 158 to 161 & 163. The focus shifts to 162 on a different tab of the same layout.

                            Commit Records/Requests [ No dialog ]
                            Set Variable [ $Portal_row; Value:DrugsUsed::__ID ]

                            Loop

                            Go to Portal Row [ Select; Next ]
                            Exit Loop If [ DrugsUsed::__ID=$Portal_row ]

                            End Loop
                            Go to Field
                            [ DrugsUsed::rx_Aim ]

                            • 11. Re: Portal sorting
                              nicolai

                              Getting there.

                               Swap around the first two lines:

                              Set Variable [ $Portal_row; Value:DrugsUsed::__ID ]

                              Commit Records/Requests [ No dialog ]
                               

                              Loop

                              Go to Portal Row [ Select; Next ]
                              Exit Loop If [ DrugsUsed::__ID=$Portal_row ]

                              End Loop

                              Go to Field [ DrugsUsed::rx_Aim ]

                               

                              If you have more than one portal on the layout you will need to go to a Field on that portal first, before you start looping

                              You need to reset the tab order - go to Layouts menu and select "Set tab order", then you can adjust the tab order on your layout

                               

                              • 12. Re: Portal sorting
                                philmodjunk

                                Instead of go to field, you can also select the portal object while in layout mode and use the name box in the Inspector to give it an object name. You can then use go to object ["objectNameHere"] Just before Loop to put the focus on the correct portal before you start looping through portal rows.

                                Go to object, BTW, can be used to open popover or select specific panels of a tab or slide control if you use the same box in the inspector to give the tab, slide or popover panels an object name.

                                • 13. Re: Portal sorting
                                  tays01s

                                  I've tweaked the script. It appears now to maintain focus on the portal, but is still failing to get into the field of the required portal row:

                                  Set Variable [ $Portal_row; Value:DrugsUsed::__ID ]

                                  Commit Records/Requests [ No dialog ]
                                  Go to Object [ Object Name: "DrugsUsed_Loss" ]

                                  Loop

                                  Go to Portal Row [ Select; Next ]
                                  Exit Loop If [ DrugsUsed::__ID=$Portal_row ]

                                  End Loop
                                  Go to Field
                                  [ DrugsUsed::rx_Aim ]

                                  • 14. Re: Portal sorting
                                    tays01s

                                    I'm a duffer. The above script works when I refer to the correct TO (DrugsUsed2 not DrugsUsed).

                                    This is v. useful functionality; thanks Nicolai and Phil.