RecordRef and MODIFY

doktordoktor Member Posts: 28
edited 2007-11-08 in Navision Attain
Hi,
I have this problem. I work with recordref and I change any fileds of record. But when I modify this record, the fields which I modify are OK, but the fields which were filled before execute code and I don't modify theirs, they are blank.

CODE :

RecordRef.OPEN(18);
Fieldref := RecordRef.FIELD(1);
FieldRef.VALUE('ABC001');
Fieldref := RecordRef.FIELD(2);
FieldRef.VALUE('ABC market');
IF NOT RecordRef.INSERT THEN RecordRef.MODIFY;

The problem is this, when I open the Recordref all his fields are blank. How can I set filter for RecordRef and then I fill fields which I want and the fileds which I don't change stay same like before execute the code?

Comments

  • pduckpduck Member Posts: 147
    this sounds that navision inserts the recordref instead of modifying it.

    what happens when running the code two times ?
    do you CLOSE the recordref clearly ?
  • jreynoldsjreynolds Member Posts: 175
    You need to GET or FIND the record you want to modify before you set the values of the fields.
  • doktordoktor Member Posts: 28
    Yes, but how? I work with RecordRef and each Record has different count of keys. I don't know how I have to set filter for record
  • Timo_LässerTimo_Lässer Member Posts: 481
    doktor wrote:
    RecordRef.OPEN(18 );
    Fieldref := RecordRef.FIELD(1);
    FieldRef.VALUE('ABC001');
    Fieldref := RecordRef.FIELD(2);
    FieldRef.VALUE('ABC market');
    IF NOT RecordRef.INSERT THEN RecordRef.MODIFY;
    RecordRef.GetTable(Cust);
    Fieldref := RecordRef.FIELD(1);
    FieldRef.VALUE('ABC001');
    Fieldref := RecordRef.FIELD(2);
    FieldRef.VALUE('ABC market');
    IF NOT RecordRef.INSERT THEN RecordRef.MODIFY;
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • doktordoktor Member Posts: 28
    sorry but this work exactly how my code. When I try this i modify fields which I change, but which I don't change and they don't blank after modify they are blank. I think it is abou how I filter record which I want to modify.
  • jreynoldsjreynolds Member Posts: 175
    Try this
    RecRef.OPEN(18);
    FldRef := RecRef.FIELD(1); // No.
    FldRef.VALUE := '10000';
    IF RecRef.FIND('=') THEN BEGIN
      FldRef := RecRef.FIELD(2); // Name
      FldRef.VALUE := 'ABC Market';
      RecRef.MODIFY;
    END;
    
  • doktordoktor Member Posts: 28
    Thanks,
    it works....
  • gjgarciasmgjgarciasm Member Posts: 47
    Hi,

    I have a very similar problem.

    I want to modify a table with a recordref and I not able to achieve it. While i am debugging I can see that my code apparently works and the new values are changed but, at the end of the execution, the table remains without changes.

    VARIABLES:

    boolInsert boolean
    locrecimport record table Import
    LineRecordRef recordref
    LifieldRef fieldref

    CODE

    boolInsert := FALSE;
    locrecImport.GET(codeImport);
    LineRecordRef.OPEN(DATABASE::Import,FALSE);
    LinefieldRef := LineRecordRef.FIELD(locrecImport.FIELDNO("No.")); //No. is th PK of the Import table
    LinefieldRef.VALUE(codeImport);
    IF LineRecordRef.FIND('=') THEN BEGIN

    recField.RESET;
    recField.SETRANGE(TableNo,DATABASE::Importaciones);
    recField.SETFILTER(FieldName, '%1','EDI Problem Flag*');
    IF recField.FINDSET(FALSE, FALSE) THEN BEGIN
    REPEAT
    IF FORMAT(LineRecordRef.FIELD(recField."No.").VALUE) = '' THEN BEGIN
    boolInsert := TRUE;
    LinefieldRef := LineRecordRef.FIELD(recField."No.");
    LinefieldRef.VALUE(textProblemFlag);
    LineRecordRef.MODIFY(TRUE);
    END;
    UNTIL ((boolInsert) OR (recField.NEXT()=0));

    END;
    LineRecordRef.CLOSE();




    I am not very experimented with recordref but I have tested every thing I know.

    Can anybody help me?

    Thank you and my best regards.
Sign In or Register to comment.