[CLOSED] Validate duplicate record with Auto sync on store.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Validate duplicate record with Auto sync on store.

    Hi,

    In ext V2.5, need to prevent duplicate record insertion on store when inserting new record with same existing data. By Using store.sync() method we are inserting/updating/deleting the records from database. A scenario like the store contains ID,Name,Value properties, here ID, Name fields are unique. When inserting same Name into database, checking in the query and returning without record insert, in this case getting message like "Key value is not defined for inserted record".

    How to handle this exception?

    Thank you.
    Last edited by Daniil; Jun 10, 2014 at 5:16 AM. Reason: [CLOSED]
  2. #2
    Hi @iansriley,

    To handle that error we can suggest the following.

    First of all you should not add a record to e.ResponseRecords if that record fails validation and set some cancel flag which you can access in another page's method (probably, a Page's variable).

    if (!validationFailed) {
        e.ResponseRecords.Add(record);
    } 
    else 
    {
        cancel = true; // You should be able to access 
    }
    Then you should handle a Store's AfterDirectEvent like that.
    protected void Store1_AfterDirectEvent(object sender, AfterDirectEventArgs e)
    {
        if (cancel)
        {
            e.Response.Success = false;
            e.Response.Message = "Error Message";
        }
    }
    Also you can set this for the Store to avoid a default failure window
    ShowWarningOnFailure="false"
    and listen to a Store's Exception client event to show an error as you need:
    <Listeners> 
        <Exception Handler="alert(operation.getError());" />
    </Listeners>
    Here is an example. Please try to insert a record and click the "Sync" button.
    https://examples2.ext.net/#/GridPane...SqlDataSource/

Similar Threads

  1. [CLOSED] Store Sync order of operations
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Nov 14, 2013, 1:21 PM
  2. Replies: 11
    Last Post: Oct 29, 2013, 5:32 PM
  3. [CLOSED] How to sync-up paging after inserting a Store record?
    By vadym.f in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Jul 22, 2013, 2:44 AM
  4. Sync store problem
    By Spamme in forum 2.x Help
    Replies: 1
    Last Post: Apr 18, 2013, 4:29 PM
  5. How to add mask for Store.sync()
    By devil in forum 2.x Help
    Replies: 2
    Last Post: Apr 01, 2013, 2:15 PM

Tags for this Thread

Posting Permissions