Cannot save the record as it has been modified by other user

havhav Member Posts: 299
Hi All,
I am facing problem with concurrent record updation. My use-case is as described below:
I am having a 3rd party application which uses its own database WMSYNC. This database has a table "WMProduct" which stores various product details. The structure of this table is as below:
ProductNo int PrimaryKey
ProductType int
Description xml
UnitQty float
Weight float
Cost xml
Price float
Updated smallint
I am using NAV 2009 NA SP1 running on demo databse NAVSYNC. I have created a linked table in NAV that refers to "WMProduct" table of WMSYNC. The table design is as follows:
ProductNo int PrimaryKey
Updated smallint

The Updated column in "WMProduct" table can assume two values viz 0 or 1.
If Updated = 0 then it indicates that the product is added/edited by 3rd party application and hence is a candidate for synching with NAV item.
If Updated = 1 then it indicates that the product is synchronised with NAV item.

I am working on a development whose aim is to synchronise products of WMSYNC with items of NAVSYNC and viceversa.
I have used COM automation in NAV that provides interface to 3rd party application.

I have written synchronisation logic as below:
WMProduct.RESET;
WMProduct.SETFILTER(Updated, '=%1', 1);

IF WMProduct.FIND('-') THEN
BEGIN
   REPEAT
   BEGIN
      .......
      //Synchronise NAV Item record with WMProduct
      IsNAVProductSynchronised := SynchroniseNAVProduct(WMProduct);
      .....
   END;
   UNTIL WMProduct.NEXT = 0;
END;

The SynchroniseNAVProduct() function is as written below:
SynchroniseNAVProduct(WMProduct : Record WMProduct) OK : Boolean
//Purpose: To synchronise Cost of NAV Product with WM
//Input: curent WMProduct record
//Output: boolean value

//Get Item record corr. to current WMProduct record
OK := Item.GET(WMProduct.ProductNo);   //Item is a record var. of Item table

IF OK = TRUE THEN
BEGIN
   //Get PRODUCT COM corr. to current WMProduct record  
   PRODUCT := PRODUCTS.Get(WMProduct.ProductNo);
   Retval := PRODUCTS.ErrorCode;

   IF Retval <> 0 THEN
      OK := FALSE       //Fail product synchronisation
   ELSE
   BEGIN
      PRODUCT.Description := Item.Description
      ........ 
      PRODUCT.Cost := Item."Unit Cost";
      PRODUCT.Price := Item."Unit Price";
            
      PRODUCTS.Put(PRODUCT);  <--Error: "Cannot save the record as it has been modified by some other user"
      Retval := PRODUCTS.ErrorCode;
            
      IF Retval <> 0 THEN
         OK := FALSE;   //Fail product synchronisation
   END;
END
ELSE
   UpdateErrorLog(TEXT012, Item.TABLECAPTION, WMProduct.ProductNo);

Note that the PRODUCTS and PRODUCT are COM autaomation variables. The PRODUCTS.Get() will read the WMProduct record from WMSYNC database and will set the corresponding properties of PRODUCT COM.
Here i then update the PRODUCT COM properties from the corresponding Item record.
The PRODUCTS.Put() will then update the WMProduct table of WMSYNC database.

The problem i face is when i call PRODUCTS.Put(), NAV throws an error "Cannot save the record as it has been modified by some other user".

The understanding that i have is that i am fetching the current WMProduct record in NAV and then updating it via COM function. Since the same record is being modified by 3rd party application, NAV identifies it as a conflict between two different versions of WMProduct record and hence it throws the error.

I am not sure how should i resolve this error.

Please help.

Thanks,
Hemant
Regards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)

Comments

  • havhav Member Posts: 299
    I need immediate help on this.
    Can anyone has any idea?
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • David_SingletonDavid_Singleton Member Posts: 5,479
    hav wrote:
    I need immediate help on this.
    Can anyone has any idea?

    Certainly.

    Contact your Navision partner or (if you are a partner) Microsoft. Log a support call and you will get an immediate response, since that's their job and what they are paid for.

    This is a volunteer community, and you should not expect immediate help.
    David Singleton
Sign In or Register to comment.