Changing Item "No."

Hi developers,

I’m having a small but very important problem with the form Item Card, we need to calculate the item “No.” concatenating another 3 fields. On practice… when a user inserts a new record on Item Card, value of “No.” is ‘TEMP’ and then the user fills de fields “Item category code”(01), “Product group code”(002) and “Item Ref.”(0001) (personalized field). When the three fields are filled I want to change the “No.” from ‘TEMP’ to (‘010020001’) in the example.

I tried just with an assignment in the “Item Ref.”.onValidate (“No.” := “Item…”+“Prod…”+…), I tried too with the RENAME function… anyway it asks the user for confirmation or it just display a message (“Another user has changed the …”).

Anybody knows how to solve it? [:D]

Disable insert in Item card. Create a new button, menu item, whatever. That new option will display a form to user enter item code. That form will create a new item record and it will lead to user to new created item.

I thought about something similar, but I didn’t want to create another form object, anyway is a good solution.

Thanks Nuno :wink:

Hi, I think, what you wrote is correct. But in onvalidate you have to comment the code and apply this. And another thing you have to make the no. series in the item setups as manual not automatice. Then you can do as you said. All the best. Try it. sasidhar.

I don’t agree with Item numbers like that. Those three fields are different attributes of the Item table and should not be concatenated into one single field. What happens when someone wants to change the category structure, are you going to change all Item numbers in the entire database?

Anyway, what I would probably do is change the behavior of the Item Card and force the user to enter those three fields before inserting a record. That way you don’t have to rename anything. You can follow Nuno’s advice and create a new form. You can also turn on the DelayedInsert on the Item Card form, and add some logic to the OnInsert trigger of the Item table to not allow an insert if those three fields are not entered. You would also have to modify the validation code in the “No.” field to not automatically populate the field with the next number from the numbering series.

Agree. This is the way to identify records (here, Items) in old systems where the only way to find an item was by the itemNo; in NAV it is possible to search for an item by name, price, group, … And by defining keys reports/lists may be sorted as desired.

First I would explain to the customer how NAV works. Only if the customer have some heavy arguments I would modify the system. And then it would be done as Nuno Maia wrote.

I think it would be much easier (even for your customer) to change the input logic, i.e., the user should type in Item.“No.” (as usual) and in the OnValidate trigger you can check (and fill) the other 3 fields (“Item Category Code”, “Product Group Code” and “Item Ref.”)…
This should only be possible if the user (users) knows the allowed codes for the 3 fields (in practice this is often the case; exeptionally one could press F6 in one of the fields in an existing item card before pressing F3 to create a new item)
If the user has always to use the lookup functions (if there are many categories, product groups, etc.) in order to create a new item no., you should use the DelayedInsert=Yes property of the form. Furthermore you have to put some code into the OnInsertRecord trigger of the item card:

// <— put here some tests that all 3 fields are filled…
“No.” := “Item Category Code” + “Product Group Code” + “Item Ref.”;
EXIT(TRUE);

This seems to work, but there may be a problem if none of the 3 fields is filled by the user but instead “No.” is filled… - may be you should set the “No.” textbox to Editable=No in the item card form, because any direct input into “No.” would be overwritten by input into the other 3 fields anyway…

Well, it seems that was a “hot” question.

I agree when you tell about not concatenating fields of the same table, but it’s my boss’s imperative, you know what I mean… Anyway, Item Category Code and the other fields to concatenate will never be changed, so Item.“No.” will be always the same.

With Nuno’s solution everything is working good !!!