1 Reply Latest reply on Apr 13, 2012 9:17 AM by philmodjunk

    Scripting error/bug inserts text in wrong field

    mJn

      Title

      Scripting error/bug inserts text in wrong field

      Post

      Hello FMP users.

      I have a database in which records are lockable via a LOCK FLAG field (set to = either "LOCKED" or "EDIT"). This field itself is visible as a radio button with text coming from a VALUE list.

      I have custom privileges set so that records can only be modified/edited when LOCK FLAG = "EDIT".

      This almost works except the radio buton itslef is also locked when the record is locked...therefore I cannot use the radio button to unlock the record (a solution to this woudl be most helpful!)

      As a work around, I created two buttons: "LOCK" and "EDIT" that each trigger a script that states:

      LOCK - Insert Text [Select; Table name::LOCK FLAG; "LOCKED"]

      EDIT - Insert Text [Select; Table name::LOCK FLAG; "EDIT"]

      Until recently these worked perfectly. 

      Now, after simply editing the layout of the database, the same scripts write "LOCKED" or "EDIT" into one of the other fields (one with data in it!). And they no longer cause the LOCK FLAG to change!

      I have remade the script and it still keeps doing this. Old copies of the database are fine UNTIL I enter the layout mode. Upon exiting the layout mode (after perhaps double-clicking on any one of the fields to view the data it is pointing to), the scripts continue to be corrupted permanently.

      I am flummoxed. It looks like a FM bug to me. I see the same problem when running the database on FMPro 10 and FMPro 11.

      Any suggestions? The field that is getting overwritten is a VERY IMPORTANT text field so I can't scrap it. Would it be safe to duplicate it and rename somehow? But how can I then make the script modify the correct field?!?

      Or if there is a way to resolve the radio button being locked (i.e. a way to keep that button permanently unlocked), that would be a way to avoid scripting entirely *but that doesn't solve the bug!

      Hoping for some help! Matt

        • 1. Re: Scripting error/bug inserts text in wrong field
          philmodjunk

          This almost works except the radio buton itslef is also locked when the record is locked...therefore I cannot use the radio button to unlock the record (a solution to this woudl be most helpful!)

          Use a script set to "run with full access privileges"--a check box at the bottom of your script editor to modify this field.

          Use Set Field to modify your radio button field. Insert script steps will fail if the specified field is removed from your layout--perhaps that's the layout change that you made?

          I'd write a "toggleLockStatus" script like this and use button set up to format your radio button field as a button to perform it:

          If [Table name::Lock Flag = "Locked" ]
             Set field [ table name::Lock Flag ; "Edit" ]
          Else
             Set field [ table name::lock Flag ; "Locked" ]
          End If

          Another option is to put the radio button field in a different table linked in a one to one relationship to the original table. Then it will not be affected by the "lock" on a given record.