6 Replies Latest reply on Feb 25, 2011 10:59 AM by DeShawnJackson

    Allow field to be modified only if...

    abitech

      Title

      Allow field to be modified only if...

      Post

      Hello,

      I have a data field in my batabase that is automatically filled with a date 2 months from another date field. Example:

      Last visit date= 01/01/2011 (inserted manually)                

      Next visit due date= 01/03/2011 (updated automatically)

      I know how to make the second field not modifiable, but I would like to allow modifying only after entering a comment on why the date has been changed. My idea would be:

      1) a pop-up window opens and asks "Why are you changing the date?";

      2) the operator enters some text in the pop-up, which is then saved into a text field;

      3) the pop-up closes down and the operator can modify the date field.

      If he/she doesn't write anything, a pop-up says "You can't change the date without giving an explanation!", the field stays as it is and can't be modified. Can anyone advise me on how to do this?

      Thank You.

      abitech

        • 1. Re: Allow field to be modified only if...
          Sorbsbuster

          In the dialogue that asks for the comment, ask for the date that it is to be moved to.  Then use a script to post the comment and update the date.  You can still leave the field as not accessible in browse mode on the layout.

          • 2. Re: Allow field to be modified only if...
            abitech

            Thanks, but I dn't have that dialog, I still have to create it.

            • 3. Re: Allow field to be modified only if...
              DeShawnJackson

              I would like to do something similar...When the item is marked as obsolete or completed, I would like for all fields in the selected record not be modifiable. However, if the user would like to change an obsolete item back to the status of new (with the click of a button), then the fields would again be modifiable. I would prefer not to use account privileges to accomplish this. Any suggestions?

              • 4. Re: Allow field to be modified only if...
                abitech

                I have made it, thanks! Asking for the new date first using a separate script has been useful in avoiding a sort of a "loop" of the script.

                • 5. Re: Allow field to be modified only if...
                  philmodjunk

                  I would like to do something similar...When the item is marked as obsolete or completed, I would like for all fields in the selected record not be modifiable. However, if the user would like to change an obsolete item back to the status of new (with the click of a button), then the fields would again be modifiable. I would prefer not to use account privileges to accomplish this. Any suggestions?

                  My suggestion is to use account privileges for this as that will be easier to set up in most cases and avoids issues where users find a way around the lock by using a different layout or due to the developer failing to "lock" a field on a layout. Why do you not want to use Access Privileges for this?

                  Options that do not rely on Access privileges require you to set up some kind of locking scheme on each and every field.

                  You can set a validation rule on each field that rejects all input if the lock field is set to a specific value. This, unfortunately, permits the user to attempt the edit, but rejects all input and requires them to revert the changes--so that can be a bit "clunky".

                  You can set up script triggers on every field using "onObjectEnter" that run a script or scripts that check to see if the lock field was set. If it is set, it uses go to field or go to object to move the cursor back out of the field. Figuring out a good place to put the cursor that does not confuse your users can be a challenge here.

                  • 6. Re: Allow field to be modified only if...
                    DeShawnJackson

                    I will be using the database myself as well as a few others and my account privileges would be set to all access. When I am actually using the database, I do not want to accidentally change a record that is marked as obsolete or completed. I know I could probably set up a separate user account for when I am in data entry mode as opposed to making layout changes, but if I need to make a minor change to the layout, I would prefer not to sign out and back in again. 

                    I don't mind doing the extra work to create a script if necessary, but before going that route, I wanted to see if there was an easier way.