RecordRef ChangeCompany FieldRef use to update field values

itinkiamitinkiam Member Posts: 37
I'm trying to update field values across all companies. Never to be accused of making something too simple, perhaps that's what I'm doing. I run this algorithm and only the record in the company that I'm on is changed. I've put a call to my function in each field that I want to run the update.

Oh. And I think this really should be simple because all of the fields that I'm updating are boolean.

What am I doing wrong? Help?

SetupChange(FieldNo : Integer;Value : Boolean)

IF locCompany.FINDSET THEN REPEAT
thisRec.CHANGECOMPANY(locCompany.Name);
IF locCompany.Name <> COMPANYNAME THEN BEGIN

thisRec.GET();
CLEAR(RecordRef);
RecordRef.OPEN(50007,FALSE,locCompany.Name);

FieldRef := RecordRef.FIELD(FieldNo);
FieldRef.VALUE(Value);
RecordRef.MODIFY;
END;
UNTIL locCompany.NEXT = 0;

Comments

  • matteo_montanarimatteo_montanari Member Posts: 189
    itinkiam wrote:
    I'm trying to update field values across all companies. Never to be accused of making something too simple, perhaps that's what I'm doing. I run this algorithm and only the record in the company that I'm on is changed. I've put a call to my function in each field that I want to run the update.

    Oh. And I think this really should be simple because all of the fields that I'm updating are boolean.

    What am I doing wrong? Help?

    SetupChange(FieldNo : Integer;Value : Boolean)

    IF locCompany.FINDSET THEN REPEAT
    thisRec.CHANGECOMPANY(locCompany.Name);
    IF locCompany.Name <> COMPANYNAME THEN BEGIN

    thisRec.GET();
    CLEAR(RecordRef);
    RecordRef.OPEN(50007,FALSE,locCompany.Name);

    FieldRef := RecordRef.FIELD(FieldNo);
    FieldRef.VALUE(Value);
    RecordRef.MODIFY;
    END;
    UNTIL locCompany.NEXT = 0;

    Hi

    you must do
    RecordRef.GET;
    //processing

    or
    IF RecordRef.FINDSET THEN
    REPEAT
    //processing
    UNTIL RecordRef.NEXT = 0;

    Bye

    Matteo
    Reno Sistemi Navision Developer
  • BeliasBelias Member Posts: 2,998
    at a first look i don't know...i seldom use recordref, so i've always to use the online help :mrgreen:
    BTW, did you try to use gettable function instead -see online help-? (i'm just guessing)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • itinkiamitinkiam Member Posts: 37
    \:D/ THANK YOU!!! Here's the new code that worked...


    IF locCompany.FINDSET THEN REPEAT
    thisRec.CHANGECOMPANY(locCompany.Name);
    IF locCompany.Name <> COMPANYNAME THEN BEGIN

    thisRec.GET();
    CLEAR(RecordRef);
    RecordRef.OPEN(50007,FALSE,locCompany.Name);
    RecordRef.FINDFIRST;
    FieldRef := RecordRef.FIELD(FieldNo);
    FieldRef.VALUE(Value);
    RecordRef.MODIFY;
    END;
    UNTIL locCompany.NEXT = 0;
Sign In or Register to comment.