NetTalk Central

Author Topic: Validate for duplicate values  (Read 1936 times)

lkeyser

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
    • Email
Validate for duplicate values
« on: June 08, 2014, 11:57:31 AM »
I have the following scenario.

I have many required fields on my form, but the most important field is the social security number.
My problem is. The user fills in all the fields, just to find that the Number is already in the database after enter key or save button is pressed.
Is there a way to validate for duplicate value before the record is saved to the disk/ database?

If not

Is there a way to prioritize which fields are “validated” first against the dictionary?   
Many thanks
Louis
Clarion 8
NT 8.15

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Validate for duplicate values
« Reply #1 on: June 08, 2014, 02:30:33 PM »
Hi Louis

There is indeed a way and it is one of the great features of NetTalk - Immediate Validation.  This property is set to 'Yes' by default for fields and it means that you can test the validity of a field immediately after the user completes that field.

If you look at your field properties you will find a tab called 'Client Side', there you can tick 'Send new value to server' and press 'Server Code' and you can enter your editing code.  If the field is in error (then you can set a message and set other fields (if say a percentage discount was too high you can reset to the standard discount and recalculate the net value).

There are two other things to do: insert any fields that could be changed as a result of your editing in the 'Reset' box and check 'Value' (what you want to re-display) and reload the session variable.  So, in the case of the invalid discount you would recalculate the net value based on the standard discount and reset. 

Also, while the field that you are dealing with will have its value placed in the session variable if you are going to do calculations with other fields don't forget to load them up into the file variables from the current session values.

In the discount example, say there were three fields: gross, discount and net - the Server Code for the editing of the Discount field might look like this:

if SAL:discount > 0.3
   SAL:Gross = p_web.gsv('SAL:Gross')
   SAL:discount = .25
   SAL:Net = SAL:Gross  * (1 - SAL:Discount)
   SAL:Message = 'Discount cannot be greater then 30%, reset to default')
   p_web.ssv('SAL:Net',SAL:Net)   
   p_web.ssv('SAL:Gross',SAL:Gross)
   p_web.ssv('SAL:Discount',SAL:Discount)
   p_web.ssv('SAL:Message',SAL:Message)
END

And you would insert all of the fields into the Rest box and get immediate response to an invalid entry.

Cheers

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: Validate for duplicate values
« Reply #2 on: June 08, 2014, 08:27:18 PM »
Good answer Keith

lkeyser

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
    • Email
Re: Validate for duplicate values
« Reply #3 on: June 09, 2014, 12:36:38 AM »
Keith

Thanks found my problem, resetting values after sending the session Value back to server did the trick

Regards
Louis