November 21, 200718 yr Is there a way to trigger a custom dialog box if the user tries to modify data in a field? For example, date in field is 1/30/06 and the user is changing it to 11/21/07. When they begin to modify the data, can a box pop up that instructs them what they need to do before changing it?
November 21, 200718 yr You could make the field itself a button that runs a script. Have the script end by entering the field.
November 21, 200718 yr Author OK that would work except I wouldn't need it to run on the initial data entry. I only need the script to run if the date has been changed. Is there something that I can put in the script that would only run it if the field was not empty when I clicked into it? Bear with me...I haven't been in my FM world for about a year so I'm a little rusty.
November 21, 200718 yr Hm. I thought you wanted to "instruct them what they need to do BEFORE changing it". Why else would they click into a field, unless it's to change it? Anyway, to run a script AFTER data has been modified, you will need a plugin. Any event-trigger plugin should suffice, here are 4 that are free: EventScript DoScript ZippScript PLUGINEX (this is the example plugin that comes with Advanced) Is there something that I can put in the script that would only run it if the field was not empty when I clicked into it? This is something else again. This you could do without a plugin, with a script like: If [ not IsEmpty ( Yourfield ) ] Show Custom Dialog [ ... ] End If Go to Field [ Yourfield ]
November 21, 200718 yr Author I think the script steps at the bottom would work for what I am looking to do. I'll have to give it a shot. I just didn't want the user to have to go thru the custom dialog and everything if they were entering the data for the first time. I forgot about the "IsEmpty", looks like it will do the trick. If not, then I'll check out the plug-ins. Thanks again.
November 22, 200718 yr i have the same problem and the solution seems to work. However, I would like this script to apply to all my fields in order to protect them from being modified by mistake. That would require a separate script for each field since the script includes the "field name" within it. I have over 50 fields. Is there a way to create one script that would do this for all fields?
November 23, 200718 yr It is hard to explain this so I attached a demo file. Basically it uses the ability to name objects in filemaker 8.5. You then use the script parameter function to pass the name of the object into the script. This should accomplish what you want with one script. The advantage of this solution is it uses a global field as a temporary holding field so the user can type in the dialog and then click cancel and it won't change anything. fieldcheck.fp7.zip
November 24, 200718 yr Contrary to the PM I sent you earlier, I actually can't get it to work I imported the script from you database into mine. I modified the script and used my table name, etc . . I entered the script parameter in the button for the actual field I was entering the info into. But clicking on the field doesn't do anything. i have included the script below. If you could go through it and see why it isn't working i'd greatly appreciate it. Script : Set Variable [$Field ; Value:Get(ScriptParameter)] Set Variable [$FieldContents; Value:GetLayoutObjectAttribute($Field; "content")] If [isEmpty ($FieldContents)] Go to Object [Object Name: $Field] Else Set Field [hn database original data::Global_field; $FieldContents] Show Custom Dialog [ Title: "Data Entry"; Message: "Are you sure you want to modify data?"; Buttons: "Yes" , "Cancel" ; Input #1: hn database original data::Global_field, "Field"] If [Get (LastMessageChoice) = 1] Go to Object [Object Name: $Field] Set Field [hn database original data::Global_field] End If End If
November 24, 200718 yr I entered the script parameter in the button for the actual field I was entering the info into. Have you named that field into the object info ?
November 24, 200718 yr i am not sure what you mean? pretty much what I changed were any parts of the script that referred to specific parts of his database. i changed them to reflect the values in my database.
November 25, 200718 yr That field ( and every others ) must be named in layout mode by inserting the name into the "object info" window. That name must be passed as script parameter.
November 25, 200718 yr I did enter the name of the field into the script parameter when I created the buttons for each field. I tried naming the Object like you suggested but that doesn't change anything. I went back to the original file from Tanner that you can download above and it doesn't seem like he named his objects and it works for him so I'm not sure if that is the solution. Please help!
November 26, 200718 yr I think the problem might be that you are applying the object name to the field after you have assigned it as a button. I don't know if it makes a difference or not but I assigned the object name before I specified the script that was attached to that field. That is why when you look at the fields on my solution it appears that it doesn't have an object name. If you click on the field and then ungroup that object you will see that it does have an object name. So I would click on the field, go to the format menu and select "button setup". Assign the button to "Do Nothing", then click ok. Then assign the object name to the field. From there you would then assign that field the object name. Hopefully that will work for you. I attached a picture of where you enter the object name just in case you didn't know. Edited November 26, 200718 yr by Guest
November 26, 200718 yr I forgot to mention one thing. One thing to be aware of is that if you tab into the field the script will be bypassed so the dialog will not come up. A simple way to avoid this is to take the fields out of the tab order on the layout. If this is not acceptable then you may be forced to use a plugin like event script or something like that.
December 2, 200718 yr For those browsing this series of posts, I have finally used eventscript, a free plug-in, to perform this action. It works very well. I am very new to databases but I can anticipate problems with plugins. The reason I say this is that if you ever update to a newer version of FMP or if you switch PCs, you have to reinstall the plug-in. I'm sure there are other reasons to use native scripts instead of plugins. So if anyone out there has an algorithm that will do the same thing event script does using the native scripts please post it.
Create an account or sign in to comment