4 Replies Latest reply on Jun 23, 2015 10:19 AM by hanstrager

    Layout script trigger

    hanstrager

      Title

      Layout script trigger

      Post

      I have a small database to hold receipts for different project.

      I now need a way to easily keep these project separate, and to see if I've re-nvoiced the different companies for what i've spend on their behalf.

      I have a 'master' layout where I type in all the information relating to a receipt. Then I thought I'll make another layout for all different companies. I then enter the the 'companyX' layout in list mode which should only show the records relating to companyX. I've tried different things but nothing seems to work.

      I've tried to add a script-trigger to the layout with the following script:

      Freeze Window

      Show All Records

      Enter Find Mode [ Specified Find Requests: Find Records; Criteria: Transactions::CLIENT: “ALEX EAGLE” ] [ Restore ]

      Perform Find [ Specified Find Requests: Find Records; Criteria: Transactions::CLIENT: “ALEX EAGLE” ] [ Restore ]

      Sort Records [ Keep records in sorted order; Specified Sort Order: Transactions::Invoiced; ascending Transactions::DATE; ascending ] [ Restore; No dialog ]

      It performs the search, but doesn't stop, and first stops when i press 'esc'. What do I do wrong?

        • 1. Re: Layout script trigger
          philmodjunk

          Did you use the on Record Load Trigger instead of OnLayoutEnter.

          This script will trip any OnRecordLoad trigger so if OnRecordLoad is used to perform the above script, you will get an infinite loop.

          I would think that you need to use OnLayoutEnter and you can remove some redundant/unnecessary steps here to perform this:

          Perform Find[ Specified Find Requests:Find Records; Criteria: Transactions::CLIENT: “ALEX EAGLE”] [Restore]
          Sort Records[Keep records in sorted order; Specified Sort Order:Transactions::Invoiced;ascendingTransactions::DATE;ascending] [Restore; No dialog]

          But setting up a different layout for every client doesn't seem very practical unless you will never have more than 2 or three clients.

          It's pretty easy to use one layout for all your clients, but limit the records shown on it to those specified by a client ID in a global field or variable. (An ID is better than a name as client names are not unique and subject to change.)

           

          • 2. Re: Layout script trigger
            hanstrager

            It was the OnRecordLoad that was the problem.

            Thank you a  bunch. it's now working.

            The reason for this set up, is that I for now only have 3-4 clients. Some are one-off clients, others are are coming back for other projects. The projects last usually 6-10months. so thought if I'll get another client I just add another layout, since the rate I'll be adding more clients will be quite slow. I see your point, getting loads more clients will be very impractical. This is just the only way I could think up a solution, without making it very complicated for only a few clients. Do you have any other specific solution in mind?

            • 3. Re: Layout script trigger
              philmodjunk

              If the only difference between one client and the other is the records you want to see, you only need one layout with scripts that control what records appear on that layout at a given time.

              Here's one example script:

              Enter Find Mode []
              Set Field [ Transactions::Client ; Get ( ScriptParameter ) ]
              Perform Find []
              Sort Records [Restore ; no dialog ]

              and one slightly different:

              Enter Find Mode []
              Set Field [ Transactions::Client ; Globals::gCurrentClient ]
              Perform Find []
              Sort Records [Restore ; no dialog ]

              The same script, the same layout, but with transaction records for different clients depending on what value is passed to the script as either a script parameter or stored in a global field. With the latter, you can set up the gCurrentClient global field with a drop down list where you select the desired client from a value list.

              • 4. Re: Layout script trigger
                hanstrager

                Ahh - don't know why I haven't thought about that... Thank you