3 Replies Latest reply on May 8, 2013 3:13 PM by philmodjunk

    script to find customer previous orders/jobs

    JohnTurner

      Title

      script to find customer previous orders/jobs

      Post

           A script to find customer previous orders has probably been well documented in the past but I am unable to find one in the forum listings - can anybody help - it would be much appreciated even if you only point me in the right direction. Thank you. 

        • 1. Re: script to find customer previous orders/jobs
          philmodjunk

               The details will depend on what you have in your database that records which orders/jobs belong to a specific customer. Ideally, you have a related table of customers that link to the orders table by a CustomerID serial number. If you do, you can use GoToRelated Records to find all orders records for a given customer.

               If you don't have that ID number based relationship, a script can use the customer's name to search your orders table, but this is less than ideal as the customer's name may not have been entered consistently on each order and you may have more than one customer with the same name.

          • 2. Re: script to find customer previous orders/jobs
            JohnTurner
                 Thank you for your fast response.
            I have a related table of customers that link to the orders table by a CustomerID serial number (Primary key) with a CustomerID (Foreign key)in the Orders table.
                  
            My script is as follows
                  
            Commit Records/Request [Skip data entry valadation;no dialog]
            Allow user abort [off]
            Go to Related Record [Show only related records;from table "Orders" ; using layout "Prevoius Orders" (Orders)]
            View as [View as list]
            Pause/Resume Script [Indefinitly]
            Perform Script ["Go to Previous Layout Orders"]
                  
            Even though I have highlighted, "show only related records" and ticked, "match current records" in my Previous Orders layout the script lists all records in the current found set.
                  
            I have probably made a simple mistake in the script but try as I like I can not find my error.
            Please help it would be appreciated.   
            • 3. Re: script to find customer previous orders/jobs
              philmodjunk

                   I would guess that you are on the orders layout when you do this. The script should work correctly when performed from layout based on customers.

                   You have this relationship:

                   Customers----<Orders

                   If you add a new Tutorial: What are Table Occurrences? of Orders that matches by CustomerID like this:

                   Customers------<Orders-----<Orders|SameCust

                   then this version of the GTRR step should work:

              Go to Related Record [Show only related records;from table "Orders|SameCust" ; using layout "Prevoius Orders" (Orders)]