RecRef and CompanyName

crisnicolascrisnicolas Member Posts: 177
A RecRef variable can be opened with an optional parameter called CompanyName

RecordRef.OPEN(No[, Temp][, CompanyName])

NAV help for this function says: If you use the CompanyName parameter, then this function works the same as the CHANGECOMPANY Function (Record).

I'm using this on my code, but RecRef always points to the current company.
IF Company.FINDSET THEN
REPEAT
  T3.INIT;
  T3.Code := COPYSTR(Company.Name,1,10);
  RecRef2.GETTABLE(T3);
  RecRef.OPEN(3,FALSE,Company.Name);
  RecRef := RecRef2;
  RecRef.INSERT;
  RecRef.CLOSE;
UNTIL Company.NEXT = 0;
Notice that this code is only for testing purposes. All records get inserted on the same company, instead of in different companies.

Has anyone experienced that?

I'm on NAV 2009 R2 (6.00.32012)

thanks

Answers

  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    I didn't check it but I suppose your problem is related to this line:
    RecRef := RecRef2;
    
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • crisnicolascrisnicolas Member Posts: 177
    Yes it is... thank you...

    With this assignation, recref points to the same recref2 was pointing (including the company).

    How can I assign the whole record from a RecRef to another one, and change the company afterwards, or copy just the values, or...

    I tried
    RecRef := RecRef2.DUPLICATE;

    But not working
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Take a look at this post on DUG: http://dynamicsuser.net/forums/t/25130.aspx
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • crisnicolascrisnicolas Member Posts: 177
    Thank you
Sign In or Register to comment.