recSalesHeader.INSERT(TRUE); SalesSetup.GET; NextOrderNo := NoSeriesMgt.GetNextNo (SalesSetup."Order Nos.", WORKDATE, TRUE); recSalesHeader."Document Type" := recSalesHeader."Document Type"::Order; recSalesHeader."No." := NextOrderNo ; recSalesHeader.VALIDATE ("No."); recSalesHeader."Sell-to Customer No." := 'CL000001'; recSalesHeader.VALIDATE ("Sell-to Customer No.", 'CL000001'); recSalesHeader.INSERT; Rec.GET (recSalesHeader."Document Type", recSalesHeader."No."); //CurrForm.ACTIVATE; //CurrForm.SalesLines.ACTIVATE;
Comments
I missed the init.
The second insert should be a modify. Its a work in progress... :?
CurrForm.SalesLines.ACTIVATE;
to the last code of the Onpush trigger of a command button on the sales header and it goes right to the first sales line.
http://www.BiloBeauty.com
http://www.autismspeaks.org
So, I've just gone back over it and this makes a little more sense:
and THIS code asks me if I want to rename the record. I have it attached to a button on the sales order form.
It should just create a standard order for client 1 and jump the user to the first sales line.... no?
Ian
If you add the line back it asks if its ok to rename.
If your Sales Header table (36) is the same as mine, you will notice the primary key is "Document Type,No." aka you are only assigning HALF of the primary key in your first "partial" insertion. THEN assigning the other half of the primary key which would be resulting in the question "Rename record?".
When you do not have the Activation line of code, it is assumed the record is still in focus and thus it wont ask you if you want to rename the record.
--- edit ---
It also appears there is no reason for you to call the VALIDATE function. You should be executing the code in the following order: INIT, Assign Field Values, INSERT. (The OnValidate function gets called, post-INSERT, since you are assigning the field's value for the first time. Correct me if I am wrong, but if you were to modify any of an existing record's fields, related to the implied field's OnValidate function, it is then and only then that you will want to call the VALIDATE function.)
It also auto completes various other fields like document date. The default is ok by me so I make use of this.
I've checked with the debugger and by checking the sales header table - The header I am writing is correctly completed with type, next number in series, doc date, etc etc
You've got a point on the insert and then modify, its not necessary.
The record which is displayed after pressing the button is the new record, so I'm not sure what you mean by
I have the impression that its an event queue problem or something similar. I think I need to do something like 'do-all-pending-operations();' and then set the focus to the subform.
RIS Plus, LLC
RIS Plus, LLC
I do get a salesheader & it goes to the salesline.
probably change this to since at that point of the code it exists ??? what is this code supposed to do? why do you need it?
http://www.BiloBeauty.com
http://www.autismspeaks.org
If I have an order open the Rec variable points to an existing record. If I create a new SalesHeader and populate the fields I then have to get the form to 'load' this new record.
What I need to get/load/read into the form is an order (recSalesHeader."Document Type") with a reference of recSalesHeader."No."
Hence Rec.Get (recSalesHeader."Document Type", recSalesHeader."No.");
Denster, you said:
maybe I've misunderstood the function of get, but my understanding is that rec.get(x,y) gets/loads/reads the record with key x,y into the variable rec. Since the form is based on Rec it will display the newly loaded rec. Theres nothing mentioned in the docs about any implicit rename or write operation of updated values when you perform an operation on a record. If you don't explicitly write something out, any modified values are dropped, no?
Savatage, the code you posted is shorter but similar to what I had. I can't see how are you getting nav to display Order002 instead of Order001 and why are you then clearing the keys?
You said to change the rec.get code
However since nav has an Implicit 'With Rec begin....' around all code in a form Rec.Get ("Document Type", "No.") is just a short way of saying
Which should have no effect at all since it will reload the current record... no?
by clearing it It made the code keep adding new orders with each click.
http://www.BiloBeauty.com
http://www.autismspeaks.org
Maybe you need to do a Currform.UPDATE(TRUE) before creating the new sales header. Maybe you will need to do Rec.INIT and build the new order straight into Rec. Debug the process and see what is going on.
RIS Plus, LLC
It worked for me - whats isn't it doing for you?
http://www.BiloBeauty.com
http://www.autismspeaks.org
My form is a copy of the standard order form with a few fields and buttons removed to simplify it down... so far only a few but I will be removing all but the essentials.
I copied your lines onto a button and the rename dialog appears. I have 'default Nos.' marked and 'Manual nos.' unmarked on the series. It appears if I execute any currform.xxxx function. If I remove the line it creates a new record but does not display it... since there is nothing which is telling nav to display the newly created record I'm not sure how this is working on your system.
Denster,
This is for 'sort of' retail use - only a few sales a day. Due to high staff turnover and the low usage they will make of this single nav terminal and a desire to not to have to train them on filling out all the bits of a sales form I wanted one which needed as little knowledge of nav as possible.
I have already tried doing this with the debugger enabled for break on triggers.... no use. I get to the line in question press F8 and the dialog appears. I click on ok or cancel and it continues on without having displayed any code doing a rename.
:-k I think I'm going to drop this one for now as its not exactly critical and they can just use the mouse. I'll come back to it one day.
Thanks for the help on this one guys.
Ian
I'm getting the sence that you also want info on the sales line filled like Type or something?
or is the problem that once you click the button - the order is created but the form is not displaying that new order - your still sitting on the first order. And each click of the button does create more and more orders but you want it to move to that order - do I have it correct now?
http://www.BiloBeauty.com
http://www.autismspeaks.org
now the setfilter will will bring you to the new salesorder each time.
It will also be the only order showing if you hit the list. You would have to clear filters (with ShowAll) to see all the orders.
I get no rename message.
if i click the button 100x I get 100 orders for the SET cust #
and the cursor is always sitting on the first line of the salesline subform.
http://www.BiloBeauty.com
http://www.autismspeaks.org