Page 1 of 1

validate if record already exists

PostPosted: Thu Nov 15, 2012 10:18 am
by entr04y
Hi,

I have an application where I input invoices received that are tied to a specific number. The number is unique across the invoices and used for the primary key on the table. Is it possible to validate the field that contains that number when entering it as a new record? What I mean is if I receive a duplicate invoice or am not sure if I entered it yet, can Xataface pop up a warning on the add new item form when I type an invoice number that already exists in the database into the field prior to me hitting save? It looks like field name__validate only works after hitting submit (I don't want to fill out the entire form just to find the record already exists)

Thanks!

Re: validate if record already exists

PostPosted: Thu Nov 15, 2012 10:25 am
by shannah
You would need to implement some custom javascript for this. You would do this in 2 parts:
1. Create a custom action that takes an invoice number and tells you if it exists. Probably returns a JSON response.
2. Create a javascript function that makes an ajax call to your action, and attach this to your invoice number field's change event.

-Steve

Re: validate if record already exists

PostPosted: Thu Nov 15, 2012 10:44 am
by entr04y
OK... I'll give that a go...

Thanks!