Hello together,
we made a Upgrade from NAV 2009 R2 to Nav 2013 R2 everything is working, but i try to test our individual Client Programmins. In this Function we Copy Records from one Company to another. For this we use the Standard Function CHANGECOMPANY and Transferfields. The function is calling from the System, i tracked it step by step over the Debugger, but in the Destination Company nothing is inserted.
??????
Has anybody more Information regarding the Function CHANGECOMPANY() in NAV 2013 R2 ?
0
Comments
I have just tested the CHANGECOMPANY at NAV 2013 R2, by a simple code copying a customer from one Company til another, and it Works fine.
Customer_loc.CHANGECOMPANY('CRONUS TRIMIT 2013 Test BASIS');
Customer_loc := Rec;
Customer_loc.INSERT;
MESSAGE('Copied.');
Did you try using the boolean return value as a check?
thanks for your tests and answer. I found the Problem.
CustomerRec.Changecompany(Companyname);
CustomerRec.Transferfields(Rec);
IF NOT CustomerRec.INSERT THEN
CustomerRec.MODIFY;
This Code are not working. The last 2 Lines.
The recommendation you received was to make newrec:=Rec.
Seems nice and simple.
http://mibuso.com/blogs/davidmachanick/
@BlackTiger
CustomerRec.CHANGECOMPANY(Companyname);
The Variable Companyname is a Parameter from the Funkction.
TRANSFERFIELDS used with CHANGECOMPANY appears to be a problem in 2015, but not 2009. If you use TRANSFERFIELDS with the second parametre set to FALSE, the problem goes away.
Why this is I do not know, but there is clearly some difference between how 2009 and 2015 respond to the TIMESTAMP field in SQL at the time of MODIFY. Adding the FALSE parameter seems to work so I am now doing this in my code base - I just hope there are no consequences of this not detailed in the manual