Hello all,
Is the following code valid in Navision?
RecA ponits to a Table with PK: Document Type, Document No, Line No.
RecB also points to the same table.
IF RecA.GET("Document Type"::Order,'123',10000) then begin
RecB := RecA;
RecB."Document Type" := RecB."Document Type"::Quote;
RecB."Document No." := '123';
RecB."Line No." := 0;
RecB.Modify;
End;
In other words, Can you modify a Rec, if you have updated the values in Primary key for the Rec all in the same routine/function?
Thanks.
-SD
0
Comments
If you want to change any primary key value, you must do a RENAME instead of MODIFY. In this case that would cause serious problems though, because you are trying to change an order line into a quote line. Without also creating a header for that line, you'd have no way of ever seeing your 'new' line.
If your goal is to create a copy of your order lines as quote lines, you should use the copy document functionality. Create a new blank quote, click functions/copy document, and you should be able to browse to an order that you can copy.
RIS Plus, LLC
Thanks,
-SD.
I would do something like this:
RIS Plus, LLC
Your response is what I would recommend too ! I just wanted to confirm with another sr. developer like yourself, so that I know that I am NOT smoking ganja or something!! :roll:
The problem is that we have several installations of Navision all across the world, every where else the same code does not give any problems but here in US we are getting an error message.
Here is the code:
here is the Error Message:
"
The reason you get the 'another user has modified...' error is that you GET the record in Rec, and then you try to modify it in RecModify. Navision thinks the one in Rec is still valid and throws an error when it tries to modify THAT one.
If it were any non-primary key value I would not even copy the rec into another variable, and do something like: Although I highly doubt that this code will work if the fields are indeed part of the primary key. There's just no reason to use a different variable when you're modifying an existing record. The 'another user...' error is because your Doc variable is not updated with the DocModify values, or because Navision is confused abiout how you can change a record that you didn't retrieve in the first place.
By the way, if your code does not give you the "The record does not exist" error, then those fields are probably not part of the primary key.
By the way 2, you don't need to do TRANSFERFIELD(FALSE), because FALSE is the default value.
RIS Plus, LLC
Use it only if you are sure that none exist ( use the developers toolkit to check it ).
RIS Plus, LLC
Even though a RENAME is very slow and the TRANSFERFIELDS-INSERT (new record )-DELETE (old record) method is much faster, this has a big drawback : It does not update any tables with fields that have a table relation to this PK.
Use it only if you are sure that none exist ( use the developers toolkit to check it ).
I cant use this for renaming "No." of customer table because it is related to many tables.. Am I wrong?
Thank you