10 Replies Latest reply on Mar 21, 2017 10:24 AM by luffyfilemaker007

    How to Refer to current record after sort.

    luffyfilemaker007

      Hi guys;

       

      I would like to know how you refer to the record you are  currently on in a script.

      And by "currently on" I mean, the record open where the script button is located and will be triggered.

       

      Because my script goes off this record to collect data from an other record and then should set that data in a field on this starting record but it doesn't seem to work.

      script iuoiu.jpg

      Do you have any idea what is wrong ?

       

      Sincerely;

        • 1. Re: How to Refer to current record after sort.
          Hudi

          You are "losing" your found set when you Go To Related Record using the same layout. I also see that you're using Enter find mode (2) and then Perform find (3), which seems unnecessary (but that's not your issue, I think).

           

          Try this:

           

          Store the original record id in a variable, go to your target record (either with GTRR or a find), then perform another find on the original id (Enter find mode, Set field, Perform find). There are other ways to do this that may be more efficient but this will definitely work.

          • 2. Re: How to Refer to current record after sort.
            philmodjunk

            Lines 7 and 8 make no sense. What are you trying to accomplish with them?

            1 of 1 people found this helpful
            • 3. Re: How to Refer to current record after sort.
              luffyfilemaker007

              HI,

              What I am trying to do is to come back on the layout with my original Record.

              And then set the found variable increment by one in a field on this Record I have my button on.

               

              But what it is doing right now, is increment by one the value of the first record in the sorted list.

               

              Thanks for the support,

              • 4. Re: How to Refer to current record after sort.
                luffyfilemaker007

                Hi,

                 

                Thanks for your advise. Sounds like what I need.

                I am quiet new to FM so even small steps take time.

                So I start to Set Variable for the Contact_ID then perform my 1 to 7 steps

                then somehow enter find mode again and set my Id variable and go to that record?

                Then I can perform step  9 to 13 ?

                I will try my best.

                 

                Cheers

                • 5. Re: How to Refer to current record after sort.
                  philmodjunk

                  The more that I look at this script, the less sense that it makes. What exactly are you trying to do?

                  1 of 1 people found this helpful
                  • 6. Re: How to Refer to current record after sort.
                    luffyfilemaker007

                    Alright,

                     

                    My Contacts have a File Number (different from Contact_ID).

                    This Number is a Folder in a drawer where we put the IRL documents of the customer.

                    There are two different syles of Number "Normal" and "Archive". (The drawers are in different locations)

                    What I want to do is to have a Script that will change the type of the patient from "Normal" to '"Archive".

                     

                    Now where I struggle is that once you change the type, the File Number should also change. So the File Number of the Contact should be the first available Archive Number.

                    So first I sort the Archive by number and then it give my the highest number in the first record. Which I set as a variable.

                    And then I want to come back on my record where I want to change the File Number with this new Variable + 1.

                     

                    I know this will leave me with an empty Normal Number but that is another problem for later.

                     

                    I am not sure if this is clear enough .

                    • 7. Re: How to Refer to current record after sort.
                      philmodjunk

                      If you open a new window first. You can perform your Find, sort, and set variable steps before closing that window. This will keep the current record the same in your original window.

                       

                      You also do not need to change layouts since both layouts refer to the same table occurrence.

                       

                      PS:

                      A relationship or ExecuteSQL could be used to get this max value without performing a Find.

                       

                      Also, I don't see any good reason to worry about gaps in the normal series of filing codes. That would seem a normal consequence of this filing system.

                      1 of 1 people found this helpful
                      • 8. Re: How to Refer to current record after sort.
                        luffyfilemaker007

                        Oh YEAH!!!!

                        It worked easily with the Open then close new Window trick !

                        Thanks a billion !

                        The only issue is that when the script performs the Window  flickers once  but I can live with that.

                         

                        For the gaps; I worry because we are limited in IRL files space storage. Which means we use the empty Normal Files for new customers. So I would like to keep track of these empty numbers after they have been Archived.

                         

                        I will see how I can find my way around that.

                         

                        Thanks again !

                        • 9. Re: How to Refer to current record after sort.
                          philmodjunk

                          You can get rid of the window flicker.

                           

                          In the New window dialog, specify a Top or left that is something like -500 and specify a very small window size. Then there's no flicker. I always start with a visible window until I've got things working like I want as it can be easier to debug issues, then I duplicate the new window step, disable one copy and update the other to make the window appear "off the monitor edge". By keeping the original step, I can enable it and disable the other if I later find that I need to do more debugging work on the script.

                          1 of 1 people found this helpful
                          • 10. Re: How to Refer to current record after sort.
                            luffyfilemaker007

                            My word !

                            It works brilliant:)

                            Thank you so much.