Sales order / Default quantity


This is my first post here. I know little about Navision but I have a good general knowledge of all the IT stuff including programming, database…

Our main business is not retail but we have a small boutique and I try to speed up the process for sales orders processing. We have Navision Version: UK 4.00 SP2 (5.00)

I am trying to find a solution to be able to set a default quantity but I am stuck by the software restriction.

I am not able to add code on a form (we don’t have the license for that), so I try to find an alternative solution.

What I have done is set the InitValue on table 37 - Sales line and it worked until we had to process a sales using a BOM.

If we don’t explode the BOM everything if fine. But when we explode it (and we have to) there is a problem.

By default the quantity is set to 1 for the BOM and stays when we explode it and then when we post and ship the sofftware ask to put a No. in the first line (corresponding to the BOM). If we delete the value in Qty for the BOM line then it asks for a Type but if we set a type the line is emptied from it content. The only way to solve this is to delete the BOM line but it is really usefull because it is the real description of what we sell.

We use a specific form for the boutique but from what I have seen it not possible to define an initial value in a form.

I have seen solution where code can be added in the form but as we don’t have the license it is not possible. Is there another solution for may problem ?

Note: we use a barcode reader to input the No. and I have set up the No. field NextControl to itself so it goes to the next line when we use Enter or the barcode sends the CR/LF. This speeds up the process to input the lines but without that default quantity it is a little bit useless.

Hi, Julien, welcome to forum.

This modification actually causes all your problems with exploding BOM…

Without it, when you explode BOM, original line colums are all emptied, only Description column remains, and such SO can be posted.
But then your “default value” kicks in and puts 1 in Qty back again, and, as soon as you have Qty entered, NAV asks for Type and No., so Qty must be cleared first to post the SO.

Hi Julien,

Modris analysis is correct - the only way around is to code - either to default in the quantity on scanning or to amend codeunit 63 “Sales - Explode BOM” [:(]

Hi Julien,

this is all a quesiton of when you are going to call your partner to help you. You have severly damaged your system right now without knowing it. There are significant validations on the Quanity field that MUST be called. There will be issues with UOMs and outstanding quantities.

So you need to decide "Do I call my partner now and get them to make a small and relatively inexpensive mod to my system, or… do I wait till my database is damaged, and then I hae to pay them to undo the mistakes I made, redo it correctly and then write a huge routine to fix up all the corrupt data.

There is a reason that your license restricts access to these features, and that is because of the amount of training it takes to be able to use the tools.

Sorry to be the bearer of bad news like this, and I hope you have not made this mod in your live database.

I must agree with David - “BOM explosion problem” after the modification you made is NOT the only one - its only the FIRST you encountered.

So, contact your Partner ASAP, as all side effects are still to come!

Thanks for your inputs.

The modifications have been made on a test environment, so don’t worry, our live environment is safe.

Some of you point out that it can be unsafe to use the InitValue on Sales line. Could you explain why ? What is the difference between using InitValue, and actually typing the value ? Is it a trigger that will not be triggered when using InitValue ?

From your answers I understand that there is, by default, no safe functionality in NAV to set a default value for a field, and it is not possible to achieve that directly on a form. It is doable, but only at the table level (what I have tried) but then this is kind of “system wide” and the implication are not limited to the Sales line themselves.

So the only way would be by code ? I suppose that would be on the OnNewRecord event.
Then that will require to check

  • if line is part of a BOM (is there a function for that?), and if not
  • check that the item No. in in the range of the one used by the item sold in the boutique with a barcode (cross reference)
  • optionnaly test also is the login if the one used at the boutique
    Then define the default Type to Item, and the quantity to 1

I am correct ?

Julien L.

InitValue only sets the value for that particular field, without running the validation code. When you manually enter the value, the field validation code will run, and set other field values, defaults and calculated values, and it runs code to validate these values against other data in the database. By using InitValue, the system does not run all this code, it just starts out with the value.

Yes what you are suggesting can only be achieved through code. Programming any data code in any of the form’s data triggers would be a mistake though. The only code that should be in any of those triggers should be display type processing, for instance whether a field is editable, or visible, things like that. Default behavior for data entry should always be programmed in the table triggers.

We also have a default to 1 set in our system.

Somewhere in the No. - OnValidate()


By using IF Statements you can allow a code like this to happen based on specific specifications.




So basically you have 2 options.

1/ Purchase the Navision Application Builder License (it only costs a few thousand pounds) then get about 2 weeks of developer training and do it your self.

2/ Contact your partner and have them do it. Its a simple mod and wont cost much.

So far the fact that you have done this on a test database AND are asking all the right questions, AND listening to the advice and following it, shows that you know what you are doing and are going about this the right way.