Need Help....Application error message

pbare

Well Known Member
I have an application that is based on 1 table that is to be used to keep a master list of our Home Business Units. The HMCU is the only key on the table. I have code in the application that should highlight the cell in red if the user attempts to insert a duplicate record.

On the OK button, I validate that the record doesn't already exist in my table.

My code works great in my fat client but doesn't work on the web. I get "JAS_MSG317: Duplicate Keys not allowed." The error message would be fine if it at least shwoed the users which line was in error.

So this is a two part question:
1. Can I turn off JDE error message (which the WEB is showing) so that I can use my own message and if I can't
2. Can I have the cell turn red but still show the JDE message.

Any help would be appreciated since my users have been waiting for this fix for a while and nothing I seem to do seems to be working.

Thanks
Pam
 
Hey Pam,
I am making a couple of assumptions here: You have a Fix Inspect form that is in ADD mode, correct?

That is definitely weird behavior. What I usually do is:
- clear all control errors first thing in OK button pressed.
- do your field validation also in OK button pressed (setting control errors here)

If any control errors are set in this event, it should automagically inhibit the Add (which it sounds like it is not doing for you).

You can try this:
- set a flag if any errors detected in OK button pressed
- in the Add record to DB - Before event: if error flag is set, then do a Suppress Add system function

Good luck.
 
Hi Jeremy,

[ QUOTE ]
clear all control errors first thing in OK button pressed.

[/ QUOTE ]

By my XE experience, when any error exists on a data entry form, then OK Button Pressed event won't be fired. Am I missed something?

On which release do you use this technique?

Regards,

Zoltán
 
How do I capture the error - the message that I am getting isn't one that I can seem to check for.

I am not very familiar with Forms (do more work on reports) but I know that we haven't seen this issue before. Usually our own code is picked up and we can change the cell color.

The user wouldn't even care about the message, as long as the specific line that caused it was changed to a different color.

My code works great locally - it is just on the web that it doesn't work as expected.
Pam
 
Let's start with the type of form you are using:
- Is it an entry-capable GRID (headerless detail or header/detail)?
- Or is it a non-grid entry form (Fix Inspect)?

My last post assumed you were working on a Fix Inspect form, but your reply suggests line-level entry which leads me to believe you're using a grid.

[ QUOTE ]
... and nothing I seem to do seems to be working.

[/ QUOTE ]
This statement leads us to believe you've been trying things...What have you tried? Be specific.

Setting a grid cell (or FC variable) color is not enough to trigger the form engine's error processing. You must explicitly set an error. See system functions:
- Set Grid Cell Error
- Set Control Error

Use one of those when you detect a duplicate record. If you are using a grid, you should be testing for duplicates in one of the Row Exit & Changed events (probably inline) of the grid (not in the OK button pressed).

I did not mean to infer that you can clear the system generated Duplicate record error that you're receiving. You should be able to code around ever seeing it. Somehow, the forms engine is making it all the way to the table insertion logic and that's what you need to make sure doesn't happen (by setting errors at the correct spot).
 
[ QUOTE ]
By my XE experience, when any error exists on a data entry form, then OK Button Pressed event won't be fired.

[/ QUOTE ]

hi zoltan, dont you mean *post* button clicked event? (cant imagine xe would be different than -say- 8.10 in this respect).
 
[ QUOTE ]
Setting a grid cell (or FC variable) color is not enough to trigger the form engine's error processing.

[/ QUOTE ]

hehheh, i hope thats not what she meant when she said "highlight the cell in red"
tongue.gif
 
I am using a Headerless Detail form with a Grid which is entry capable (either via Excel import or typing into the columns)

For my error handling, I do a Fetch Single on my table to see if the HMCU value is already in the table.

If the Fetch is Successful(a record is found), I set the Grid cell color to red and set the Grid Cell error to 073P which is a standard error.

I am also checking for the duplicate record when the HMCU column is exited (Changed Inline) as you suggested.

I am wondering if the issue is due to the fact that the data is imported rather than entered manually.

Unfortunately, I only have this particular problem when I run it on the WEB - the FAT client is fine (code behaves as expected)

Thank you for the suggestions - I hope to get this resolved soon.
Pam
 
[ QUOTE ]
If the Fetch is Successful(a record is found), I set the Grid cell color to red and set the Grid Cell error to 073P which is a standard error.

[/ QUOTE ]

In what event are doing this fetch? If not in one of the row exit & changed events, try it there. FYI: you do not need to set the cell color...the Set Grid Cell Error will do that for you.

If you are importing data, the 'column is exited' event may not fire...I'm not sure about that. I am fairly certain that imported data will always fire the row exit & change events.

One thing that should prevent that duplicate error is to add your fetch check in the Add Grid Rec to DB - Before event. If the fetch is successful, call the system function 'Suppress Add'.
 
Hi Omer,

[ QUOTE ]
dont you mean *post* button clicked event?

[/ QUOTE ]

No, but to be sure, I just checked in the debugger on the Adressbook Master Revision form. OK Button Clicked event wasn't fired when there as an error on the form.
It was on XE SP 23.

Is it real, that this difference exist between XE and 8.1x?
Can you check also on 8.1x? Thanks.

Regards,

Zoltán
 
Hi Pam,

It is not an answer for your issue, but an addition for your duplication check.

It is not enough to check the table, you should check the grid also.
Maybe there are more row with same HMCU in the grid.

Regards,

Zoltán
 
hi zoltan,

i just checked on xe demo and 8.10 fat client, address book revision form, and this is what i saw:

- if the error is already present before ok is clicked, then you are right: [ok - button clicked] (and of course also [ok - post button clicked]) is not triggered (example: enter an invalid Business Unit, and exit the field);

- if no errors exist yet when ok is clicked, and the ok-button-validation sets an error, then [ok - post button clicked] is not triggered (example: blank out Search Type field, and then press ok).

(the same goes for grid cell errors in a headerless/detail form; tested that too).

the 2nd scenario was the one i meant (and is also the one that pam is talking about). but i have to admit that i had expected the 1st scenario to behave the same. thanx for this eye-opener.

because of 2nd scenario, usually when i need to do my own custom processing on ok, i:
- put the custom validation logic in button clicked event;
- put the processing (e.g. table i/o) in post button clicked event.
 
Seems likely that you have not formatted the HMCU. Kindly format the HMCU using the standard BSFN and then try.
 
Hi Omer,

Thanks your test and update.

I generally use something similar like 1st scenario on an update capabale form, when want to execute something that should be part of the transaction of the form - so when finally user press Cancel, it will lose also automagically.

Regards,

Zoltán
 
Back
Top