I am trying to launch a new purchase order from a code unit where the order number will be automatically assinged and the new order (blank) displayed. I am using the code below but while the new number is being assigned (no series table), the last PO is being displayed on screen instead of the new one. I have done the same with a customer and it worked no problem; it just seems to be the PO. Any ideas ? recPurchaseHeader.INIT; recPurchaseHeader.“No.” := cuNoSeriesManagement.GetNextNo(‘P-ORD’,TODAY,TRUE); recPurchaseHeader.INSERT; fPurchaseOrder.SETTABLEVIEW(recPurchaseHeader); fPurchaseOrder.SETRECORD(recPurchaseHeader); fPurchaseOrder.RUN;
I think you have to use “recPurchaseHeader.INSERT**(TRUE)**;” instead of “recPurchaseHeader.INSERT;” Default is INSERT(FALSE) so the code in the OnInsert trigger isn’t executed. And you need the code in the OnInsert trigger to add a purchase header.
The same applies to creating the new customer Shane. Creating the new number is not the only default action that the system may take when inserting a new record, and by doing INSERT(TRUE), you catch all that default behavior. Of course your goal may have been to only do that number thing and leave out al the rest of course
My aim was to show the PO screen with only the no. filled in. I thought it would have been as simple as assigning the POrec to the form and displaying it. Maybe I am missing something obvious here. I have tried the insert(true) suggestion but the results are the same.
does the form have a filter upon it that would force you to only see the record before the one you have created?
Code after suggested changes above now reads : recPurchaseHeader.INIT; recPurchaseHeader.“No.” := cuNoSeriesManagement.GetNextNo(‘P-ORD’,TODAY,TRUE); recPurchaseHeader.INSERT(TRUE); fPurchaseOrder.SETTABLEVIEW(recPurchaseHeader); fPurchaseOrder.SETRECORD(recPurchaseHeader); fPurchaseOrder.RUN; What it seems to be doing is getting the next no in the series as expected showmessage(recPurchaseHeader.“No.”) confirms this. However when the form opens, the first PO record is displayed. The last record is not the one with the new number so it appears as if the insert is not happening. Manually hitting F3 in the orders screen and tabbing off gives the next number.
Comment out the line that says “recPurchaseHeader.“No.” := cuNoSeriesManagement.GetNextNo(‘P-ORD’,TODAY,TRUE);”. Getting the next available number is taken care of by the INSERT(TRUE) command.
No still the same result. The PO is the vanilla version. Have looked at the permissions and I have write permissions. Manual insert (F3) works. I am baffled.
The following code should work: recPurchaseHeader.INIT; recPurchaseHeader.“Document Type” := recPurchaseHeader.“Document Type”::Order; recPurchaseHeader.INSERT(TRUE); fPurchaseOrder.SETTABLEVIEW(recPurchaseHeader); fPurchaseOrder.SETRECORD(recPurchaseHeader); fPurchaseOrder.RUN;
quote:
The following code should work: recPurchaseHeader.INIT; recPurchaseHeader.“Document Type” := recPurchaseHeader.“Document Type”::Order; recPurchaseHeader.INSERT(TRUE); fPurchaseOrder.SETTABLEVIEW(recPurchaseHeader); fPurchaseOrder.SETRECORD(recPurchaseHeader); fPurchaseOrder.RUN;
Originally posted by tinoruijs - 2005 Jul 13 : 08:01:31
You should also set the PO Number to blank, since Init does not do that. PurchHeader.“No.” := ‘’;
By the way Shane, be aware that in 3-6 months, your Client or the users are going to come to you and say “Damnn this Navision is a load of C$@p, why does it always make all these silly blank customers and Orders.” I generally call this “Substituting Training with Coding”. Your better solution, is to train the users to use Naviison fiunctionality. If they want Navision to be like their old system, then they just wasted a bucket load of money, and they should have stayed with what they had.
Thanks David, that worked a treat. Had the conversation with the customer about the blanks. They are aware of it and it has been documented. Thanks Again
From my eperience, once you give into a client, and do a mod that could have been done ith training, you end out rewriting the software to look like their old system, it is very easy to see if this is the case… think about all the meetings over the last couple of months, have you ever heard “… but our old system did it this way, and we would like to keep doing it that way…” to which you are supposed to reply “Well why did you buy Navision” … it i s the begining of a long battle.