Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Dialog Boxes

Status
Not open for further replies.

gaift

Programmer
Jul 10, 2006
74
0
0
US
I have a layout which will serve as an input form for data,
With filemaker you have the option to have the database save data with every key pressed on the keyboard or you can have the option of FileMaker asking the user if they want to save the data.

In my case, i would like to have the user input data and then
have a submit button which i would have a script running when the button is pressed, i will have filemaker automatically save as the user enters data (which the user will have no idea since there will be a submit button).

The way i intend to have this script run is, there will be a custom dialog box asking the user if they would like to submit to save the record where they will either choose yes, no, or cancel (cancel so they can make further changes). If they choose yes i would just have filemaker direct the user back to the view only mode with the record they have just made being the record that is shown. If the user chooses no
i would delete the record and then redirect the user back to the view only or into the input layout with an empty form.

The problem i am having is that i do not know how to link the buttons from my custom dialog to the rest of the script, such that an if statement will be checking which button has been pressed (yes, no, cancel).

i am using filemaker 7

 
So basically you want the user create a new record, fill in data and at the end a choice to 'save' the new record if the Yes button is pressed or delete the record if No ?

If the choice is Yes, you want the user end up in the just created record ?
 
In a nutshell

the user will enter data and then click on a submit button
then a custom dialog will appear asking if they wish to save
with three buttons, yes, no, cancel (cancel will allow them to
edit any information before they decide to save).

Then if the answer is Yes then the record would be "saved" (meaning the record will not be deleted) and would then take them back to the view only mode which now contains the new record.

IF No was clicked then filemaker will delete the record and take them back to the new record input form with all the data they input gone.

If the third button was clicked (maybe named, make changes to record, or cancel)
the user will be able to modify any data they may have entered before they decide to save.

To do this i need to link the buttons from the custom dialog to the script. This is where i am stuck i do not know how to get the custom dialog buttons to link to the if statements i would have in the script.
 
Basically it's not such a good idea to already create a record and then yes/no delete this record again.
Suppose you have (or will have in the future) a linked number system or serial, with deleting the record you will have to make sure the serial (or whatever system) is also reset to the previous value, and I can come up with some other reason to not follow this way.

What I suggest is to make a layout where you put all the fields needed to make a new record, but as global.

Redirect the user to this record when making a new record.
The user can fill in all the needed fields, delete data, re-enter etc.

Put 2 buttons on this layout. 1 "Cancel", 1 "Register".
Link a script to the Cancel button, something along these lines:
Set Field(fieldName1_gt;"")
Set Filed(fieldName2_gt:"")
etc for all the global fields on that layout.

This script will clear all the global fields.
This way, still no record creation and as last step you can redirect the user to whatever place you want/need.

The Register button has a script along these lines:
Create Record
Set Field (yourFirstField;fieldName1_gt)
Set Field (yourSecondField;fieldName2_gt)
etc for all the global fields on that layout.
Set Field (fieldName1_gt;"")
Set Field (fieldName2_gt;"")
etc for all the global fields

This script will create a new record, set all the needed fields to the values in the corresponding global fields and will clear the globals, ready for the next new record.

To avoid wrong or missing data in the input, you could tweak the script.
Suppose there is a need to have some fields with data in it, those fields are not allowed to be empty.
You need a way to prevent the record creation.
A way to do that is presenting the user with the Register button, only after those fields have a value.

Suppose you have a field with a constant value = 1.
Make a calculationfield, result number along these lines:
Case(
notIsEmpty(yourField1) and notIsEmpty(yourField2) etc...for all the needed fields;1)

This will result in a value 1 if all the data are in the needed fields.
Make a relationship between the constantfield and your calc field.
Put a portal on your input layout, with the registerbutton in it, the portal 1 pixel larger than your button, ni lines.
This will make the portal invisible.

Only when all the fields has data, the relationship will match, so the Registerbutton will show in the portal. No match, no button = no way to create a record....

This in a nutshell, but I think you get the idea....

HTH
 
Ok so what youre saying is if have a database that has X number of fields that compose a record, i make 2x fields first half is the fields that actually hold data the other half are global fields that will correspond to the first half.

In my input layout i have buttons that will Register the record or cancel and make the input empty. If the user presses cancel i can just set all the global fields to "".

If register is pressed i have a script that will create a new record set the non global field = to the global field that was entered and then empty the global fields and direct them back to a new record input for again and the process can start over or they can navigate to other parts of the database
 
Ok ive tried the algorithm

However the fields in the other layout where they are set to the value of the globals are not taking in the values input into the global field when i press the submit button.

What i have for the script is

New Record/request
SetField[arbitraryTable::Field 1 = Field 1 GLOBAL]
SetField[arbitraryTable::Field 2 = Field 2 GLOBAL]

SetField[arbitraryTable::Field 1 GLOBAL = ""]
SetField[arbitraryTable::Field 2 GLOBAL = ""]

etc.
 
Ok i found the mistake

Thanks for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top