6 Replies Latest reply on Feb 9, 2010 1:35 PM by philmodjunk

    Simple script driving me bonkers

    LeoB

      Title

      Simple script driving me bonkers

      Post

      What I thought should be a simple script is making me crazy -- almost enough to make me want to go out and shovel snow instead.

       

      In one table (18 fields) there are three fields concerned in this script (Status, SuspenseDate, DateClosed).

       

      Status is auto-set to Open on record creation and has a simple Value List (Open/Closed).  SuspenseDate is not a required field as that date is usually inserted some time after the record is created.  However, it is possible for a closed issue to be reopened.

       

      Status is set to a script trigger on save that I want to:

      Open to Closed:  Clear any date in SuspenseDate and take the user to DateClosed

      Closed to Open:  Clear any date in DateClosed and take the user to SuspenseDate

       Here is the script:

      If [Issue::Status = "Open"]

         Clear [Select; Issue::DateClosed]

         Go to Field [Issue::SuspenseDate]

      Else If [Issue::Status = "Closed"]

         Clear [Select; Issue::SuspenseDate]

         Go to Field [Issue::Date Closed]

      End If

      The script works fine when going from open to closed.  HOWEVER, when going from closed to open it does clear the DateClosed field but does NOT take the user backto the SuspenseDate field.  The cursor stays in DateClosed.

       

      Any ideas amongst the wizards out there?

       

      Thanks

       

       

       

       

       

       

       

       

        • 1. Re: Simple script driving me bonkers
          philmodjunk
            

          I don't see why this would make a difference in how your scripts work, but I'd use Set Field [Issue:: DateClosed ; "" ] to clear the field.

           

          Try your script on a new layout where you've placed just the fields listed in your script and see if it works there. There may be an issue with your layout that's interfering.

          • 2. Re: Simple script driving me bonkers
            LeoB
              

            Phil:

             

            I copied the script and changed the two Clear Field functions to Set Field, as you recommended.  No change.

             

            I created a new layout from the same table with all fields and applied the same field settings to the three fields in the script (Status to the drop-down list and the other two to calendars).  I tried both scripts, and the exact same result.

             

            I created a new layout from the same table with only the three fields in the script (set Status to the drop-down list and the other two to calendars).  I tried both scripts, and the exact same result.

             

            In Manage Database/Fields the only settings for the three fields are Indexed.  I tried all variations of Validation, but no change.

             

            Thanks.

            • 3. Re: Simple script driving me bonkers
              LeoB
                

              Just to make me crazy, I created an entirely new database with one table and just those three fields and set them the same way.  I imported the two scripts, tried both, and no change.

               

              Then I deleted the imported scripts and recreated them new.  No change.

               

              Wow.

              • 4. Re: Simple script driving me bonkers
                philmodjunk
                   Try running it from a button or the script menu. I suspect the triggering record save event may be an issue here.
                • 5. Re: Simple script driving me bonkers
                  LeoB
                    

                  Phil:

                   

                  It was the script trigger.  I thought that earlier I had tried OnObjectModify, but I had been setting it to OnObjectSave.

                   

                  I went back to OnObjectModify, and it works!

                   

                  Thanks

                  • 6. Re: Simple script driving me bonkers
                    philmodjunk
                       If you end your script with Exit Script [False], it should work with OnRecordCommit if I read the help file correctly. In triggers where the trigger fires before the event, this step will cancel the triggering event.