Create a New Record without using the F3 Key

Hi, I just created a button on the vendor card that is used to create a new record, after I opened the form. How do I deal with the number series of the vendor no. on the form? In other words, what is the code that can substitute the F3 key? Sincerely, Sylvia Tsang Management Software Solutions, Inc. Edited by - yummi on 2001 Nov 30 22:03:31

The code that invokes the numbering function is in the Validate trigger for the (in this case) Vendor No. field. But I would caution you against customizing such a basic function as the “new record insert” function to have your users use a button rather than F3. I realize that they may have used a button in their old system and be insisting on one now, but if you follow this path, where do you stop? Navision’s built in functions are generally quite consistent throughout the product and once your user gets over the learning curve hurdle, which is moderately painful but usually short, they (and you) will be much better off if they adapt to the Navision defined standards. Dave Studebaker Liberty Grove Software A Navision Services Partner

Hi, David’s reply is the way to go with new users. They first need to know the basic’s before changing anything. Which will help them in the long run. PLEASE DON’T MAKE THE USER PAY TWICE. Thanks, David

I can’t agree more. Once you start down this dark path…forever will it dominate your destiny…(sorry star wars moment). If you make a “small” change like this, they will ask for it somewhere else, and somewhere else. Whenever possible staying with standard navision is not only easier but, cheaper! Bill Benefiel Manager of Information Systems Overhead Door Company (317) 842-7444 ext 117

People, don’t be to strict with yummi! In my implementation, you can not create a new item record using F3, because the Item No. textbox is Editable = No, so you can not enter the new item no. Instead we use a function “Copy Item Bom” Ctrl + F3, which makes it easy to create new records, as it copies everything except price etc. This was originally done to prevent beginners from by mistake “Rename” records, when they did what they used to do in the legacy system. I will implement the same logic in the Customer and Vendor table also, when time allows. (Making the primary key field read only gives you, as a spin off, a very simple way of finding a record; just type in the No.) The simple answer to yummi’s question is VendorX.init; … VendorX.insert; Yummi, if you debug an F3 on the Vendor card, I am sure you will be able to find out how Navision handles the number series problem. Pelle


Originally posted by pelle: The simple answer to yummi’s question is VendorX.init; … VendorX.insert; Pelle

How about Clear(VendorX); // will also clear the primary key VendorX.Insert(true); // will get the next no. from no. series is primary key is empty Kind regards, Jan Hoek Weha Automatisering BV Woerden - The Netherlands

Jan, you are absolutely right. But look at the previous example. “record.Init” method is more convenient for reliable initialization code.

<some initialization code except VendorX.”No.” := Y;>

Regards, Yuri Pokusaev IBS, Senior Consultant NCPS, NCSD +7(095)967-8080

Hi Init is not so good in this case Record.INIT Record Data type: record The record you want to initialize. This function assigns default values to each field in the record. The values the system assigns in the record correspond to those defined when the table was created. If no value was assigned when the table was created, the system assigns values based on the data type, as shown in this table: Comments The system does not initialize primary key or timestamp fields. So you also have to blank the primary key fields. Paul Baxter

Record.init; //after you use de codeunit NoseriesManagement (id 396)for the parameters refer to the trigger OnInsert of the table Vendor. record.insert;

Or Better still VendorX.Init; VendorX.”No.” := ‘’; VendorX.Insert(true); Paul Baxter

Paul Don’t forget the NO series table With your system there are not updated

Fabrice You don’t have to as it is the code on the insert trigger deals with the No Series, try Vend.INIT; Vend.“No.”:=’’; Vend.INSERT(TRUE); MESSAGE(Vend.“No.”); Vend.INIT; Vend.“No.”:=’’; Vend.INSERT(TRUE); MESSAGE(Vend.“No.”); and see two new vendors created with different numbers. Paul Baxter Edited by - triff on 2001 Dec 06 15:47:38

Thank you very, very much for the responses. They have been very helpful! Now I am wondering how do I get the following situation working? When I open the Vendor Card, I want it to display a blank record, instead of any existed record. I don’t want the user to see the empty record with a number assigned. The only way that would happen is when he/she clicks on the button, and it will show the number. Sincerely, Sylvia Tsang Management Software Solutions, Inc. Edited by - yummi on 2001 Dec 06 23:26:26

The way of obtaining the next index value is: VAR:

PurchSetup: Record(Purchases & Payables Setup);
NoSeriesMgt: Codeunit(NoSeriesManagement);
Vendor	: Record(Vendor);


NoSeriesMgt.InitSeries(PurchSetup."Vendor Nos.",'',0D,Vendor."No.",Vendor."No. Series");
MESSAGE('New values assigned: "No."=%1,"No. Series"=%2', Vendor."No.", Vendor."No. Series");

Regards, Yuri Pokusaev IBS, Senior Consultant NCPS, NCSD +7(095)967-8080 Edited by - ypokusaev on 2001 Dec 07 10:52:11

Way of doing without inserting a new record: 1) Create a new report based on the integer class (remember to set insertallowed and delete allowed to false). 2) On the report add a variable type Vendor and display it’s values on the form as if it was the vendor card. 3) On the onActivate trigger make the form always filter the number field as ‘1…VendorRecordGlobalVariable.COUNT’ and to go to the first record. 4) Onaftergetrecord IF (Number = 1) THEN Clear(VendorRecordGlobalVariable) ELSE BEGIN VendorGlobalVariable.RESET; IF (VendorGlobalVariable.FIND(’-’)) THEN VendorGlobalVariable.NEXT (Number -2); END; 5) When modifying the values on VendorRecordGlobalVariable remember to modify the values on the record if is an existant one (you’ll have to use the modify onaftervalidate in all fields) or to insert the record if it’s the new one (if number = 1). 6) When you add a record you’ll have to re-set the filter to the new count. Regards, Alfonso Pertierra (Spain) Edited by - apertierra on 2001 Dec 12 19:26:18