Problem - Insert and Modify in EP web part

naimish_hitnaimish_hit Member Posts: 111
edited 2006-08-22 in Navision e-Commerce
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
Naimish Dave
(Software Engineer)

Comments

  • MatthiasNMatthiasN Member Posts: 31
    Methinks the problem is with this ;

    HeadRecordRef.MODIFY(TRUE);


    Try without the TRUE should fix for you.


    regards, Matthias.
  • naimish_hitnaimish_hit Member Posts: 111
    Hi,

    Sorry but sstill same error occurs even I restart NAS but no success yet.

    Any other thought?

    With Best Regards,

    Naimish Dave
    Naimish Dave
    (Software Engineer)
  • peterke1974peterke1974 Member Posts: 23
    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 problem
  • IHateLinuxIHateLinux Member Posts: 223
    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,
    Rainer
Sign In or Register to comment.