Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

I have a button called "New" which creates a new record/request.

However, I'd please like to know if we can promt/notify users that a new record will be created once the "New" button is pressed...The notification/promt will be "Do you want to create a new record with two buttons. The two buttons " Ok Create New Record" and Cancel"

By doing this we can stop users creating new records if the user presses the "New" button by mistake etc.

Thank you in advance.

Posted

Okay - firstly i moved your post from open source solutions - this is where you post sample files open to the public, not make requests for them.

ScriptMaker is a better location. Anyyyway.

All you need is the following script and attach it to your "new" button.

Show Custom Dialog["Confirm" ; "Are you Sure you want to add a new record" ; "yes" ; "no"]

If[Get(LastMessageChoice) = 1]

Create New Record/Request

End If

Posted

You could also try setting the layout not to automatically commit records.

If you go the script route, there are pitfalls. If the users create a new record using the menus or the keyboard, Genx's script won't run. Conversely, if you try to catch your users on the way out with a script, there's the problem of users exiting the record without clicking the button (say, by closing the window), your script won't run.

Moreover, once your user has accidentally requested a new record, it's in the db. That's why some FM developers create a layout that uses all global fields to capture the user's input, and then script the add record, placing the global fields into a record for the user.

Posted

Thank you datatrooper. Users can only create new records via "new" button but really appreciate your input.

Just a query, how is that you create a layout that uses global fields to capture the user input. etc...sorry new to fm.

Thank you genx too for your help too.

Posted

There's no problem being new...!

You say that your users can only create records using a button--does that mean that you've locked down your solution to prevent them using the New Record or Duplicate Record commands from the menus or keyboard? If you haven't actively addressed this, it WILL be a problem down the line. It gets really troublesome when you have a user who unwittingly hits Apple-D (duplicate record) when they meant Apple-E (delete record)...

The way you have a layout with all global fields is first to create a set of global fields that parallel the field in your data table that your users enter. For example, you've got a FName data field--create a gFName global text field (many use a "g" prefix to alert themselves that the field is global). When you have all your real fields duplicated as globals, change your layout to use these global fields instead. When your users click the Add button, your script initializes all the global fields to blanks, and loads the layout. Your users put data into the global fields rather than a "real" record.

Keep in mind that you will also need an Edit script that loads a selected existing record into the global values for the user so they can modify info.

In either case, you'll have a Commit script on this layout that takes the data in the global fields and puts it into a new or existing record behind the scenes.

David

Posted

Thank you David for the inside knowledge.

I did not know how any other way so I was using a simple method. YES-- I ahve locked down my solution to prevent users using the New Record or Duplicate Record commands from the menus or keyboard?

I would like to try your suggestion as it might come handy in future.

Ok I have created couple of global fields(just for testing purposes) and changed the field to use the global field on the layout.

Now the commit script attached to the Add button. I do not know but I tried. Here is my script(gInvoiceNumber is a global field and on a layput)

SetField(TableName::gInvoiceNumber,"")

New Record/Request

Commit Record/Request

I do not know how to initialize it but maybe I am right above eh?

also Commit Record/Request...how would it know load it in the "real" record..

any ideas...

Posted

While the above mentioned regarding global entry and then basically copying to a new record is an option, it can cause you a lot of problems - i.e. you add a field to your normal layout - you have to add it to your global layout - along with an additional script step - now imaging doing this for 200 layouts - 10-15 fields a layout.

Perhaps your solution isn't necessarily that big, but anyway, this issue still needs to be considered.

In terms of the mechanics of it:

2 fields on the real layout = 2 fields on the global layout.

Get the user to input the info into the global layout, if they click "save":

GoToLayout[YourRealLayout(may or may not be the same)]

New Record / Request

SetField[RealField1 ; GlobalField1]

SetField[RealField2 ; GlobalField2]

SetField[GlobalField1 ; ""]

Setfield[GlobalField2 ; ""]

Or if they click "Cancel"

Show Custom Dialog[Title="Confirm" ; Text="Are you sure you would like to cancel the changes you have made so far?" ; Buttons:Yes,No]

If[Get(LastMessageChoice) = 1]

SetField[GlobalField1 ; ""]

Setfield[GlobalField2 ; ""]

End If

I forget the exact syntax of the dialog step, but its similar to that.

Hope this helped.

~Genx

This topic is 6704 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
×
×
  • Create New...

Important Information

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