2 Replies Latest reply on Aug 19, 2012 5:44 AM by kluetkenhoelter

    Update a checkbox using a script

    kluetkenhoelter

      Title

      Update a checkbox using a script

      Post

      I am a very new user to FMP, so forgive me is this has an obvious answer.  I am trying to update a checkbox field using a script.  The script is asking the user if they want to view open jobs.  Using a Custom dialog, I am giving them the option to choose, yes, no or cancel.

      If they choose Yes, I would like to update a Find for the field and be able to then search for all jobs that are open.  But I do not know how to update the checkbox field

      Below is 1) my script, 2) the Custom Dialog settings

      Any help would be greatly appreaciated.  Thanks in advance

       

      SCRIPT

      Go to Layout [“Projections” (Projections)]

      Enter Find Mode [Pause]

      Go to Field [Projections::Status]

      Show Custom Dialog [“Open Jobs?”; “Do you want Open Jobs?”; Projections::Status]

      Set Field [Projections::Status]

      Preform Find[]

       

      CUSTOM DIALOG SETTINGS

      Default Button = Yes, Commit Data is checked

      Button 2 = No, Commit Data is checked

      Button 2 = Cancel, Commit Data is not checked

       

      Input Fields

      Show Input field #1 – Specify “Projections::Status”

      Label:  If (Get ( LastMessageChoice ) = 1 ;

      Projections::Status = "open";

      Projections::Status  ≠  "open")



        • 1. Re: Update a checkbox using a script
          Sorbsbuster

          I think your check box should possibly be a radio button, unless you expect a record to have more than one status.

          Try this for your script:

          Show Custom Dialogue [Open jobs?" ; "Do you want to check for Open jobs?"]
          #Check for cancellation
          If [Get ( LastMessageChoice ) = 3 ]
          #Cancel chosen
          Halt script
          #
          Else If [Get ( LastMessageChoice ) = 2 ]
          #No chosen
          Enter Find Mode
          Set Field [Status ; "Open" ]
          Omit Record/Request
          #
          Else
          # Yes chosen
          Enter Find Mode
          Set Field [Status ; "Open" ]
          #
          End If
          #
          Perform Find

          You could also turn on Error Capture before the Perform Find and handle neatly the case where there are no found records.

          Note that you don't need any input fields.   Uncheck the 'Pause' on the Enter Find mode steps.

          • 2. Re: Update a checkbox using a script
            kluetkenhoelter

            Thanks, this worked perfectly!