Jump to content

Script to confirm changes to a Container field? Rollback support.


This topic is 2288 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi, everyone. I need help creating a script to trigger when a Container field is modified, as in existing contents is replaced or deleted. I would like a custom dialog box to prompt the user if they really want to modify the Container field which has already been populated with content. If they select "OK", the changes are made, but if they select "Cancel", the changes are not made to the Container field.

 

The reason this came up is because I want to prevents accidental delete or replace of a container field's contents via the "drag and drop" feature that FileMaker has. A user can easily hit the delete key while resting on the field or drop a new file onto it without considering the effects that the existing data will be gone forever. Since these container fields will hold important documents and information, I would like to add some pre-emptive warning measures on the user's side.

 

I believe this can be done via the "OnObjectModify" script trigger on the actual container field, but I've had no luck testing scripts steps. Also, I discovered that if one drags and drops a file onto a container field, the field is automatically committed, so the changes becomes final instantly. So, using the "OnObjectEnter" and maybe other available triggers might not work exactly as expected in this scenario due to the default "drag and drop" functionality committing all changes instantly. 

 

I also prefer to leave the "Save record changes automatically" option for the layout enabled. I know that leaving this unchecked will prompt you after exiting each field if any changes made should be saved, though even with this option uncheck the "drag and drop" behavior of container fields bypasses the default FileMaker warning message and allows you to overweight the existing content of the container field. I believe this is because the container field is never actually entered or exited, since a file is just dropped onto it to overwrite any existing one, and as mentioned above the changes are committed instantly. Now, if you actually do enter the container field, by selecting it, then the warning message triggers just fine.

Edited by Alex117
Link to comment
Share on other sites

45 minutes ago, Alex117 said:

I believe this can be done via the "OnObjectModify" script trigger on the actual container field, but I've had no luck testing scripts steps.

IIRC, dropping content into a field cannot be used to trigger a script.

Link to comment
Share on other sites

7 minutes ago, comment said:

IIRC, dropping content into a field cannot be used to trigger a script.

Actually, it DOES seem to work. But, only with the "OnObjectModify" script trigger set on the field.

 

If you drag and drop a file into a container field, even without having clicked into the field, it will still trigger any script defined in the "OnObjectModify" script trigger. See my attached sample file.

Container Field - OnObjectModify script trigger - drag and drop test.fmp12

Link to comment
Share on other sites

1 hour ago, bcooney said:

You could use two slide panels - one has browse off, the other browse on. Click button to edit takes you to panel that allows for edit of container field.

Thank you, that can be a possible alternative. Let's see if anyone else has a bright idea. I wish there was a way of doing this without having to click additional buttons, by just retaining the default drag and drop option openly on the layout.

 

If there could be a way to trigger a dialog box, upon the user attempting to modify the field contents, and presenting the choice to either commit changes to the field or not it would be great. I'm not fully certain if there's a workaround to this yet seeing as the current drag and drop behavior is finicky regarding script triggers and ignores certain rules. I found this message on the FileMaker website discussing the same topic:

"Testing department informed me this issue has occurred for a long time and is a design limitation.  Auto-commit occurs when dragging a file from outside FileMaker Pro into a Container field when the record is not active (not being edited)."

Link to comment
Share on other sites

This topic is 2288 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.