Problem - Insert and Modify in EP web part

naimish_hit
Member Posts: 111
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
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
Naimish Dave
(Software Engineer)
(Software Engineer)
0
Comments
-
Methinks the problem is with this ;
HeadRecordRef.MODIFY(TRUE);
Try without the TRUE should fix for you.
regards, Matthias.0 -
Hi,
Sorry but sstill same error occurs even I restart NAS but no success yet.
Any other thought?
With Best Regards,
Naimish DaveNaimish Dave
(Software Engineer)0 -
naimish_hit wrote:Hi,
Sorry but sstill same error occurs even I restart NAS but no success yet.
Any other thought?
With Best Regards,
Naimish Dave
Hello,
Did you find a sollution for this, because I have the same problem0 -
Hi,
do you have a lot of flowfields on that table?
Try to look at the function
"SupportFunctions.CompareHashValues"
This function will compare the hashvalue of the record which has been sent to SharePoint with the current hashvalue of the record in NAV to identify if someone else has modified the record in the meantime.
If you are absolutely sure, that no one has modified the record, you may change this function e.g. to ignore some fields.
HTH,
Rainer0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions