1 Reply Latest reply on Jan 2, 2012 10:59 AM by philmodjunk

    Exit Script and Halt Scrript

    fdomingues

      Title

      Exit Script and Halt Scrript

      Post

      File Maker 11 Pro on Windows XP

      Have a couple of fields with modifications controled by two scripts:

      1) Script "CheckIn", triggered by entering the controled field, sets a "token field" to the current value of the controled field, unless this is empty.

      2) Script "CheckOut", triggered when validating the controled field, compares the new value of controled field with value in "TokenField". If they arte the same the script is stoped (Halt Script). If they are different the operator has a choice of comfirming the change (Halt Script) or revert the record to the initial value.

       

      This works OK with all the fields except for a date field, "Initial_Date".

      If the field contents equals the"Token Field" or when the operator wants to confirm the changes, situations where de "Halt Script" step should stop the script, the cursor just freezes on the date field and won´t move unless a change in the value is made.

      The problem is solved when I replace de Halt Script steps for Exit Script, what comes as a surprise to me.

      Note: there is a "Final_Date" field with a calculation based on the elapsed working days from the "Initial_Date". Could this have some influence?

      Thank you

        • 1. Re: Exit Script and Halt Scrript
          philmodjunk

          You'd need to post your script so that we can see the details. Also, is the Final_Date field a date field with an auto-entered caculation or is it a field of type calculation? Either way, posting that calculation could help as well.

          I do something similar in one of my databases, but I use these two scripts:

          Script 1 to save original value:

          #This script saves the pre-edit value of the current field in a global field: $$OldValue. It is performed from an OnObjectEnter Trigger.
          #Parameter: GetFieldName is used to pass the name of the field being entered as the script parameter.
          Set Variable [ $$OldValue; Value:GetField ( Get ( ScriptParameter ) ) ]

          Script 2 to confirm whether to save change or revert to original value

          Set Variable [ $fieldName; Value:Get ( ScriptParameter ) ]
          If [ not IsEmpty ( $$OldValue ) and ( $$OldValue ≠ GetField ( $fieldname ) ) ]
                 Show Custom Dialog [ Title: "Confirm Change"; Message: "Replace previous value with this change?"; Buttons: “Save”, “Revert” ]
                 If [ Get ( LastMessageChoice ) = 2 // Revert was clicked ]
                         Set Field By Name [ $fieldname; $$OldValue // revert field back to previous value ]
                 End If
          End If

          To post a script to the forum:

          1. You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
          2. You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here.
          3. If You have FileMaker advanced, you can generate a database design report and copy the script as text from there.
          4. If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format. (Use the HTML option on the database tab panel and paste the text into the forum's HTML editor.)