First Q : I want to add validation before saving records in database but write method doesn't called and records save without getting the error message .
How to make write method called and records doesn't save if getting the errror ?
second Q :
I want to make priority field in table to be an auto increment and show automatic when click on add button so I wrote code on init value () datasource method and made a method on table but it gets the max priority on table not on table in this loan item .
how to fix this ?
Try adding the logic in leave method of LoanItem DataSource. Leave method will be called when you leave the current record.
It will return a Boolean value. So, throw an error or warning if the ratio is less than 100.
Thanks,
Girish S.
I get it . I will try to save data in temp table , which method can I do it before saving data ? , save data in temp table if no error insert data from temp
That returns as to my first reply. The method validating a record before saving is validateWrite().
You rejected it with "but it return the error on record level not on all record"; it seems that you want to save records without a validation and runs a validation against saved records.
which method can I used to run before saving records ?
You asked for running a validation at a point where records are already saved, so throwing an exception won't change what already happened.
If you want users to insert several records, then run a validation and decide whether all the records should be saved in database or not, it means that you need to store the records somewhere else before the validation and copy them to DB if the validation succeeded. You can use a temporary table for that.
I tried it on written () on data source it is running but save data even if throw error . can I make records don't save until click on save or save if it doesn't throw error ?
I checked leave method on Grid - Leave method is called whenever we close this form - LostFocus method is never called.
So, it's better to add the code in the form closed method and add the error message as per your scenario.
Thanks,
Girish S.
I am not sure why the leave and lost focus method doesn't get called. Also try debugging the code.
Do a find reference on the leave and lostFocus method and see whether this method was used in the standard logic.
Thanks,
Girish S.
I want to validate records when I leave tab page that have grid .
like leave of lost focus but It doesn't called .
Do you know any ways to execute these method or why not called ?
Try adding the validation logic in form Closed method. Closed method will have return type as Boolean.
During closing of the form this method will be called. If you add code here it will check the condition - If it is false, then it won't allow you to close the form until the value is given as greater than 100.
public boolean closed() { boolean ret; ret = next closed(); // add select statement to get total allocation ration. if(allocationRatio < 100) { ret = checkfailes("Error message"); } else { ret = true; } }
Check whether this work around suits your scenario,
Thanks,
Girish S.
André Arnaud de Cal...
292,160
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156