7 Replies Latest reply on Aug 19, 2010 4:01 AM by user14040

    Current Contracts Script

    user14040

      Title

      Current Contracts Script

      Post

      Hi

      I have a script  that will show expiration date of machines but how do I get it to show machines that contracts are current?

      Here is the expiration script I tried to edit, but when the script is perform by pressing a button it shows all machine, expired and current contracts:  How do I just show the current contracts starting with current date?

      Freeze Window
      Go To Layout [Rep Contract List]
      Enter Find Mode []
      Set Field [Equipment::ExpDate & "<" & Get ( CurrentDate ) - 0]
      Set Error capture [on]
      Perform Find[]
      If [ Get ( FoundCount ) > 0 /* Current Contract Found */]
         Refresh Window
         Sort Records [no dialog ; restore] //specify a sort order that makes sense to you
         Show Custom Dialog ["Contracts that Are Current"]
      Else
         Go TO Layout ["MAIN MENU INTERFACE" (CUSTOMERS)]
      End If

      Thanks

      L

        • 1. Re: Current Contracts Script
          philmodjunk

          Is Equipment::ExpDate a date field? (not a text field?)

          Assuming it is a date field and you want all records where the expiration date has not expired, you'd use this expression:

          Set Field [Equipment::ExpDate ; ">" & Get ( CurrentDate ) ]

          There are two specify buttons for set field. You click the first button to select the field to the left of the ;. You click the second button to enter the expression shown to the right of it. Do not try to enter the ";", it will be added for you when you click OK after entering the expression.

          • 2. Re: Current Contracts Script
            user14040

            Yes it is a date field.

            I tried the set field, but it still showed all expiration dates.

            Set Field [Equipment::ExpDate ; ">" & Get ( CurrentDate ) ]

            I used this code without the [ & ] it gave and error so I added it, but it still did not work.

            Equipment::Exp Date   &   ">" & Get ( CurrentDate )

            • 3. Re: Current Contracts Script
              philmodjunk

              If you are entering: 

              Equipment::Exp Date   &   ">" & Get ( CurrentDate )

              Then you have an error somewhere in what you are doing.

              It must look like this:

              Set Field [Equipment::ExpDate ; ">" & Get ( CurrentDate ) ]

              When you review your script in the script editor.

              Check the directions in my earlier post again. Make sure you are clicking Specify Target Field Specify to select Equipment::ExpDate and clicking calculated result: Specify to enter the text to the right of the semi-colon.

              Also, I am assuming that your Rep Contract List layout refers to Equipment in its "Show Records from" box in Layout Setup... If it doesn't that may also cause problems for you.

              • 4. Re: Current Contracts Script
                user14040

                you are correct i was making a mistake in the code.  it worked thank you so much.

                • 5. Re: Current Contracts Script
                  user14040

                  I have one more question.

                  Within the list of machine under contract I have a value list that list the type of contract a customer has, how do I exclude all machines with a value list of NP?

                  NP short for No Plan

                  • 6. Re: Current Contracts Script
                    LaRetta_1

                    In your script, immediately after your Set Field[], insert these lines:

                    New Record/Request

                    Set Field [ Equipment::ContractType ; "NP"  ]

                    Omit Record

                    ... then resume your script.

                    • 7. Re: Current Contracts Script
                      user14040

                      Thanks so much it worked