Hi, I need change the current record of the Sales Invoice Subform (form 47). In order to do so I use GET(key). Unfortunately instead of changing the currently selected record the system is asking to rename it. If I set DelayedInsert=No navigation works fine but lots of other things in the sales lines don’t. I tried also using NEXT(), FIND etc. and got the same lousy result. Can anyone suggest a workaround? Regards, Petko
Have you tried to define a new Record variable (SalesLine) and do something like: SalesLine.GET("Your Key"); Rec := SalesLine;
I’m not sure about it… Good luck
I already tried that one and it doesn’t work. It is trying to update Rec with myRec (SalesLine).
…another one would be to use .SAVERECORD, before moving to the next (or whatever) record. It forces Navision to save the current record.
Already tried. Doesn’t work.
Can you elaborate a bit more on this then. What you’re trying to do? You have an existing set of records and trying to move to a next one or? Paste the source code if possible.
Are you using the right document type and documetn number when using the GET?
I have a function that adds a new record to Sales Lines table based on a cross-reference supplied. **************** myFunc(crossReference : Code[20]; salesHeader : “Sales Header”) myRec.INIT(); myRec.“Document Type” := salesHeader.“Document Type”; myRec.“Document No.” := salesHeader.“Document No.”; lastRec.RESET(); lastRec.SETRANGE(“Document Type”, Rec.“Document Type”); lastRec.SETRANGE(“Document No.”, Rec.“Document No.”); IF lastRec.FIND(’+’) THEN myRec.“Line No.” := lastRec.“Line No.” + 10000 ELSE myRec.“Line No.” := 10000; myRec.Type := Type::Item; myRec.VALIDATE(“Cross-Reference No.”, crossReference); myRec.VALIDATE(Quantity, 1); myRec.INSERT(TRUE); GET(myRec.“Document Type”, myRec.“Document No.”, myRec.“Line No.”); ******************* The GET above generates the “Rename” message. I need to position the current line focus on the new record.
Put a COMMIT; before the GET(xxx,xxx,xxx).
Problem is that form is Editable, so on GET in form is identified as modify/rename; Use UPDATE in post modification trigers OnAfterValidate, OnAfterGetRecord … after modification. GET in modification trigers will work like modification, in others like navigation.
Nikola, I don’t think that is good idea is COMMIT. Never use COMMIT if you can !!!
Dalius, GENERALLY it is never a good idea to use COMMIT if you can avoid it. But in the case given there is nothing to worry about, e.g. inserting row or rows into a NON-LEDGER type table 37 Sales Line, is not like putting a COMMIT into middle of a function posting 50000 records from a journal, isn’t it? Using a COMMIT is sometimes necessary, to work around certain cases. I do agree that it should be used with extreme caution and NEVER during a customisation of a posting procedure (although MS/Navision themselves are doing this;) ).
I can’t say it’s worth worry or not, because I don’t see all code. Maybe he after call doing athers modifications or verifies. It’s enought easy to move GET in OnAfterValidate triger.
Dalius, I don’t fully understand your idea. My function is not called within a triger. It is called onPush of a button on the master form (invoice). I tried a scenario with calling UPDATE before using GET but it still doesn’t spare me the rename message.
So COMMIT didn’t work?
No. COMMIT; GET(myRec.“Document Type”, myRec.“Document No.”, myRec.“Line No.”); still tries to rename the record instead of just navigating the form.
instead of GET write something like that: SETRANGE(“Line No.”,myRec.“Line No.”); CurrForm.UPDATE(false); SETRANGE(“Line No.”);
10x Viktoras, this hack WORKS, but I’m still looking for a “proper” solution. Petko
why are you looking for “proper” solution? why you think it’s not good?
Because this is filtering which by occasion changes the current record. It also involves too much blinking and scrolling in the form.