Record Save

Questions and Answers about DataEase for Windows

Record Save

Postby flapster » Thu Sep 20, 2012 8:31 am

I have a DataEase application that i have inherited and am trying to make a small enhancement although never having used DataEase before i need a bit of help :(
There is a form with a Save button and the action is set to "Record Save". I want to replace this with some code that will check if any fields have been changed and then warn the user with a messagebox "are you sure" and then save the record if answered yes.
Sounds simple but where do i start ? [-o<
flapster
 
Posts: 3
Joined: Wed Sep 19, 2012 9:36 am
Has thanked: 0 time
Been thanked: 0 time
 

Re: Record Save

Postby Phil Winkler » Thu Sep 20, 2012 12:10 pm

Hi, flap,

Welcome to the forum and the world of DataEase/Ffenics.

90% of the work with DataEase is analysis.

WHY do you want to do this? What business purpose is being served?

Also, what version of DataEase are you using and where are you located?
Phil Winkler
PLM Consulting, Inc.
pwinkler@plmconsulting.com
Phil Winkler
 
Posts: 889
Joined: Fri Sep 07, 2007 12:45 pm
Has thanked: 0 time
Been thanked: 0 time
 

Re: Record Save

Postby Adrian Jones » Thu Sep 20, 2012 12:35 pm

DataEase (and Ffenics) should do this out of the box, except that it's sort of round the other way -- if you try to close a document with unsaved changes, you'll be prompted to save or abandon changes.

It's rather unusual to want to prompt users if they mean to save something when they've just clicked a save button. More likely to want to do that if they are about to delete.
User avatar
Adrian Jones
 
Posts: 2000
Joined: Tue Sep 11, 2007 2:38 pm
Location: Cornwall, UK
Has thanked: 5 times
Been thanked: 4 times
 

Re: Record Save

Postby flapster » Fri Sep 21, 2012 2:03 pm

I am using dataease 6.52, am in the UK.
The user sometimes enters values in particular fields but not that often, so if they happen to enter a value then press Enter i want to pop up a message box e.g. "you have changed field ABC to value XYZ are you sure you want to?"
Am not sure where to start...
flapster
 
Posts: 3
Joined: Wed Sep 19, 2012 9:36 am
Has thanked: 0 time
Been thanked: 0 time
 

Re: Record Save

Postby Phil Winkler » Fri Sep 21, 2012 2:11 pm

You could start by creating 'echo' fields that contain the original data in each field you need to test. Then have a msg field/script that evaluates the 2 and either pops up a msg or doesn't. Perhaps the fieldname.value Property could also be used in a script. Take a look at the Help file examples of scripts in the OML Guide.

But, heck, it is their data so let them be responsible for it. What you are trying to do sounds downright annoying to me. Sort of like some websites for shopping.
:roll:
Phil Winkler
PLM Consulting, Inc.
pwinkler@plmconsulting.com
Phil Winkler
 
Posts: 889
Joined: Fri Sep 07, 2007 12:45 pm
Has thanked: 0 time
Been thanked: 0 time
 

Re: Record Save

Postby Adrian Jones » Fri Sep 21, 2012 2:49 pm

OK, my concern is in your first message when you say you've never used dataease before, and what I'm about to suggest is relatively advanced, but ...

You can add some scripting to the document to do this.

First, do it on an aspect, not a form. If the document you are trying to change is a form, save it under another name.

Second, in order for the following to work, you will need to add a record to the external functions form like below:

-- Start of ELF record --------------

Function name: Message
Description: Custom Message Dialog & Processing
ELF Library Name: MsgBox.DLL
Return Type: Int
Param 1 -- Name: Text Message
Param 1 -- Type: String
Param 2 -- Name: Caption Title
Param 2 -- Type: String
Param 3 -- Name: Icon Display
Param 3 -- Type: Int
Param 4 -- Name: Button Selection
Param 4 -- Type: Int
Param 5 -- Name: Beep Sound
Param 5 -- Type: Int

-- end of ELF Record --------

Make sure the function name has exactly the case shown here, with an upper case 'M' and rest lower case. The other values don't need to be strict on case.

Now open up your new aspect in designer view, right-click on a field whose editing you want to control, and select scripts.

In the script editor, make sure the field you want to control is shown in the box next to the label at the top "object list". Then in the list to the right of this, labelled "Event list", choose the event PostEdit.

In the white text box below this, paste the following in as your script. Chang e the message to make sense.

-- Copy from below --------

if message ( concat ( "you've changed First Name from " , value , " to " , string , " . Are you sure?" ) , "Wait a mo" , 4 , 4, 0 ) not = 7 then
return 2 .
end

-- to after the word end, and make sure you also have a return after end

Press F2 to compile, then F4 to run it. This should pop up a message confirming the before and after vaues, and return the value to the before if you click 'no' on the message.

== WHAT IT MEANS ========

The message function takes 5 parameters: the actual message, a title for the dialog, a number indicating the buttons to show, another for the icon, another for a beep.

concat joins various things into a single string of text. The word 'value' is the actual content of the field BEFORE it was changed; string is the new value being submitted.

The message function returns a number indicating what button was clicked -- yes is button #7. So if they did not click 'yes', you return 2, which is basically the scripting way of saying false.

The PostEdit event occurs after a value is changed, and if it returns false, that is a way to reject any values changed and restore the pre-editing value.

I think it should also leave the recordstate as unchanged, which will mean the user is not also prompted to save again later.

Obviously, try this on a single field first before going further. And I repeat, try it on an aspect.

PS: As you're in the UK, you might like to consider my Fforward with Ffenics workshop in Bristol Nov 5-6th...
User avatar
Adrian Jones
 
Posts: 2000
Joined: Tue Sep 11, 2007 2:38 pm
Location: Cornwall, UK
Has thanked: 5 times
Been thanked: 4 times
 

Re: Record Save

Postby flapster » Mon Sep 24, 2012 1:30 pm

Hi Adrian, thanks for your reply.

I'm not sure if my version of Dataease is the same as yours, there are some things in your note that i don't understand.

I don't know what an "Aspect" is. I searched the Help but there isn't any reference to an Aspect.

Regarding the message box, i had experimented a little myself as i knew that i needed a message box as the pop-up. This is what i changed :

1. I opened the Form in design view, then selected the Save button, right-clicked and chose Action. Here it was set to Record Save.
2. I created a new Procedure and typed the following :

Message "test popup" window.

and saved it as MSGBOX.

3. I changed the Action for the Save button to Open Procedure and selected MSGBOX.

So now when i click on the Save button i get the popup.

If i were doing this in Visual Basic for example, my pseudo-code would be something like :

[In the Save button click event]
Check if any of the "special" field values have been changed on the Form from what's in the database.
If not -> do the same thing as the existing form i.e. whatever "Record Save" is doing.
If values have been changed -> popup the message box with details of what field(s) have been changed and what to. Ask user if he is sure he wants to continue.
If no -> do nothing
If yes -> do the same thing as the existing form i.e. whatever "Record Save" is doing.

Hopefully this all makes sense [-o<
flapster
 
Posts: 3
Joined: Wed Sep 19, 2012 9:36 am
Has thanked: 0 time
Been thanked: 0 time
 

Re: Record Save

Postby Adrian Jones » Mon Sep 24, 2012 2:17 pm

Sorry -- forgot this was DataEase and not Ffenics.

In which case swap 'aspect' for a form that does not own the table. Which basically means either that when you go the 'save as' route, the 'define new table' option at the bottom of that dialog is not checked.

Or if you start a new form from scratch, you select an existing name from the list of database tables.

The rest of my post still applies.
User avatar
Adrian Jones
 
Posts: 2000
Joined: Tue Sep 11, 2007 2:38 pm
Location: Cornwall, UK
Has thanked: 5 times
Been thanked: 4 times
 

Re: Record Save

Postby Gil Fleming » Sat Sep 29, 2012 9:10 pm

Hi flap

I'm not a DFW user but we do something similar in ffenics. The form contains two copies of each critical field (critical means any fields that you are worried about). We refer to them as unconfirmed (can be altered by the user) and confirmed (can only be altered procedurally) values. When the user changes any of these (unconfirmed) values and clicks the save button, a simple script performs a save, then runs a procedure that detects differences between unconfirmed and confirmed values. It pops up a message displaying the old and new values and asks for confirmation to commit these values. The user interacts with the dialogue with a yes or no and the procedure either commits the values (confirmed := unconfirmed) or reverts the values (unconfirmed := confirmed). We use this technique in stock-critical areas of order processing. I would use it with care as it does slow things down somewhat.
Gil Fleming
Director
Fleming Technical Limited

You can't think about what you don't know - Mike Fidler
If you can't fight, wear a big hat - John S Fleming
The best way to have a good idea is to have lots of ideas - Linus Pauling
Gil Fleming
 
Posts: 546
Joined: Tue May 15, 2012 10:26 am
Location: Liverpool, UK
Has thanked: 1 time
Been thanked: 2 times
 
 

Return to DataEase for Windows

Who is online

Users browsing this forum: No registered users and 2 guests

cron