1 2 Previous Next 16 Replies Latest reply on Apr 27, 2017 11:25 AM by sawhat

    Prevent field editing?

    sydbarker

      I am trying to create a script that pops up a dialog whenever a field that already has a value is being modified. Only problem is I am using a script trigger, so it pops up the message even when the record is blank. How can I make sure that the message only appears whenever a field that has a value is being changed?

       

      The script I'm using is

       

      Show Custom Dialog ["Field Save"; "Are you sure you want to modify this field? A value already exists."]

      If[Get(LastMessageChoice) = 2]

           Revert Record/Request[No dialog]

      End If

        • 1. Re: Prevent field editing?
          coherentkris

          if ( not ISempty ( The_field ) ; show dialog ; dont show dialog )

           

          Be judicious about using irritant messages like this because it impedes the users data entry in order to promote data integrity..

           

          K

          • 2. Re: Prevent field editing?
            sydbarker

            So I tried this instead in order to make it a script

             

            If[IsEmpty(CFF BD Management::Contact Relationship)]

            Exit Script []

            Else

                 Show Custom Dialog ["Field Save"; "Are you sure you want to modify this field? A value already exists."]

                 If[Get(LastMessageChoice) = 2]

                      Revert Record/Request[No dialog]

                 End If

            End If

             

            It is set to be a script trigger on object modify, but it still pops up the message even when the field is blank.

            • 3. Re: Prevent field editing?
              siplus

              See attachment.

              This will protect you from select all - cut, too.

              • 4. Re: Prevent field editing?
                Draco

                I suggest you vote for:

                 

                NOT EDIT FIELD WHEN

                • 5. Re: Prevent field editing?
                  sawhat

                  This works for me:

                  I use an OnEnter Trigger Script to prevent a user from modifying a key field.

                  if [Length ( Get(ActiveFieldContents)) > 0 ; Go To Next Field]

                   

                  sydbarker wrote:

                   

                  I am trying to create a script that pops up a dialog whenever a field that already has a value is being modified. Only problem is I am using a script trigger, so it pops up the message even when the record is blank. How can I make sure that the message only appears whenever a field that has a value is being changed?

                   

                  The script I'm using is

                   

                  Show Custom Dialog ["Field Save"; "Are you sure you want to modify this field? A value already exists."]

                  If[Get(LastMessageChoice) = 2]

                  Revert Record/Request[No dialog]

                  End If

                  • 6. Re: Prevent field editing?
                    philmodjunk

                    I use an OnEnter Trigger Script to prevent a user from modifying a key field.

                    And what happens if the user uses "drag and drop" to drop data into that field?

                     

                    You'll find that the field is never entered and thus OnObjectEnter is never tripped.

                    • 7. Re: Prevent field editing?
                      sawhat

                      Thanks for spotting that. I had no idea. What is the best approach to allow

                      a client to enter id_kp once and the not be able to edit it. I know can

                      prevent deletion in security/extended privileges but didn't see a way to

                      prevent editingbon a field level.

                       

                      Thanks

                      • 8. Re: Prevent field editing?
                        sawhat

                        Maybe I should just hide it when its not empty and display another field

                        with the same contents and uncheck "browse" in inspector?

                        On Wed, Apr 26, 2017 at 5:22 PM Doug Hauenstein <doug.hauenstein@gmail.com>

                        • 9. Re: Prevent field editing?
                          philmodjunk

                          The user should never, no never, ever be allowed to edit a field named id_kp. A primary key value should be auto-generated by FileMaker when the record is created.

                           

                          For other fields where you want controlled, field level edit-ability, you might place two copies of the field on the layout, one where behavior permits browse mode field access and one that does not. Use Hide Object When to control which field is visible.

                          • 11. Re: Prevent field editing?
                            sawhat

                            I certainly agree with your statement about id_kp. If there was a "Low

                            Cost" way to find all of the dependancies I would change it in a heartbeat.

                            The hiding scheme works fine for me. Thanks!

                            • 12. Re: Prevent field editing?
                              philmodjunk

                              I would make finding and eliminating the need to physcally edit primary keys a very high priority and would suggest that getting a tool such as Base Elements or Inspector to track down those discrepancies money well spent as it would save you hours of time and eliminate a vulnerability in your system that could have catastrophic consequences for the data in your solution.

                               

                              Note that it's often easier to add a new field to use as a primary key and then gradually transition relationships and data to use it than to retrofit an existing so called primary key found on many layouts to be a true "no editing allowed" primary key. You basically turn the existing field into a label field found only in the parent record and used for searches, sorting etc, but no longer as a primary key in relationships.

                              • 13. Re: Prevent field editing?
                                sawhat

                                Sounds like good advice. Ill make it a priority to get it straightened out.

                                Fortunately the critical tables have proper kp's. Thanks again for your

                                advice. Your post have been an invaluable source of information. Keep up

                                the good work!

                                • 14. Re: Prevent field editing?
                                  sawhat

                                  The reason I used a descriptive id_kp was I have not been able to figure out how to implement the following:

                                  Background:

                                  I have an OrderLines Portal on an Orders table.

                                  Each OrderLine consists of several (5) (at present) components kind of like a BOM.

                                  For Example Qty, W, L, Service1, Service2, Service3, Service4,Service5

                                  Each service may or may not be Taxable or Discountable.

                                   

                                  I use a drop downs to select services by description to lookup the price to calculate Description, Tax, Discount and Line Extension.

                                   

                                  Services are setup so a User may check or uncheck (discount, taxable, active). I have a scripts that build a lists of active Services. This lists are used to populate the drop down boxes.

                                   

                                  If there is a simpler way to allow users to add and remove services and control the other attributes I mentioned I haven't stumbled on it yet.

                                  1 2 Previous Next