Problem - Insert and Modify in EP web part

Hi, I am simply trying to insert new record in single table and after wards modify it. For above I have placed following code in C6822: InsertTimesheet(GUID : Text[50];VAR HeadRecordRef : RecordRef) HeadRecordRef.OPEN(DATABASE::Timesheet,FALSE); HeadRecordRef.INIT; HeadRecordRef.INSERT(TRUE); // Build Records to Create the Filter for Answer (Filter for HEAD) HeadFieldRef := HeadRecordRef.FIELD(Timesheet.FIELDNO(Instruction)); tmpInstruction := HeadFieldRef.VALUE; EPSupportFunctions.CreateTempHeadFilterTable(Timesheet.FIELDNO(Instruction),tmpInstruction,GUID); // Build Records to Create the Key for Answer (Filter for HEAD) EPSupportFunctions.CreateTempHeadFilterKeys(Timesheet.FIELDNO(Instruction),GUID); and following code in C 6824: ModifyTimesheet(VAR XMLDocInHead : Automation “‘Microsoft XML, v3.0’.DOMDocument”;GUID : Text[50];AdditionalValues : ARRAY [2] OF Code[ ReturnCode := 0; FilterString := STRSUBSTNO(‘WHERE(1=CONST(%1))’, DecodeXML.GetValueByFieldIDFromHeadData(XMLDocInHead,Timesheet.FIELDNO(Instruction))); HeadRecordRef.OPEN(DATABASE::Timesheet,FALSE); HeadRecordRef.SETVIEW(FilterString); xHeadRecordRef.OPEN(DATABASE::Timesheet,FALSE); xHeadRecordRef.SETVIEW(FilterString); IF xHeadRecordRef.FIND(’-’) THEN; IF SupportFunctions.CompareHashValues(DecodeXML.GetHashValue(XMLDocInHead),HeadRecordRef) THEN BEGIN EncodeXML.AddFieldToValidationDoc(XMLDocValField,Timesheet.FIELDNO(Name)); EncodeXML.AddFieldToValidationDoc(XMLDocValField,Timesheet.FIELDNO(Description)); EncodeXML.AddFieldToValidationDoc(XMLDocValField,Timesheet.FIELDNO(“Work Description”)); EncodeXML.AddFieldToValidationDoc(XMLDocValField,Timesheet.FIELDNO(Mon)); EncodeXML.AddFieldToValidationDoc(XMLDocValField,Timesheet.FIELDNO(Tue)); EncodeXML.AddFieldToValidationDoc(XMLDocValField,Timesheet.FIELDNO(Wed)); EncodeXML.AddFieldToValidationDoc(XMLDocValField,Timesheet.FIELDNO(Thu)); EncodeXML.AddFieldToValidationDoc(XMLDocValField,Timesheet.FIELDNO(Fri)); EncodeXML.AddFieldToValidationDoc(XMLDocValField,Timesheet.FIELDNO(Sat)); EncodeXML.AddFieldToValidationDoc(XMLDocValField,Timesheet.FIELDNO(Sun)); DecodeXML.ModifyRecord(XMLDocInHead,HeadRecordRef,XMLDocValField,DATABASE::Timesheet, TRUE,FALSE,AdditionalValues[1],AdditionalValues[2]); HeadRecordRef.MODIFY(TRUE); END ELSE BEGIN ReturnCode := 20; END; HeadFieldRef := HeadRecordRef.FIELD(Timesheet.FIELDNO(Instruction)); tmpValue := HeadFieldRef.VALUE; SupportFunctions.CreateTempHeadFilterTable(Timesheet.FIELDNO(Instruction),tmpValue,GUID); SupportFunctions.CreateTempHeadFilterKeys(Timesheet.FIELDNO(Instruction),GUID); I have also set appropriate lines in correspondence Codeunits for calling above functions. PROBLEM: When I press “Create New” button it inserts new blank record in table but doesnot allow to save it with any data, it give me following error: Error during Modify (20): Another user has modified the record for this Object after you retrieved it from the database. Enter your changes again in the Web Part. on other hand when insert record manualy in table it saves it and also display that record in web part, here it also allows me to modify successfully. I think Problem is only with “Create New” record. I have just copy paste above functions from same codeunits. What cause above error? With Best Regards, Naimish Dave

Hi Naimish, This is a very common error, if you search the forum you will find plenty of posts telling you the answer. The “other user” is in fact another process started by the same user. You will find your code is structured something like this: Process A reads a record Process A changes the record but doesn’t modify it yet. Process A calls Process B. Process B reads the same record and modifies it. Control now returns to process A. Process A modifies the record. Crash! Process B could be triggered by a VALIDATE so you may not be aware that it’s happening. As I said that’s a rough idea of what’s happening, I’m sure your search will bring up some better explanations. Regards, Dan.

Hi, I understand, now what you suggest towards solving above problem. I want come code for it. With Best Regards, Naimish Dave

Correct, You may want to use the LOCKTABLE syntax to prevent other users from changing the value and COMMIT.