We want to set our "Shipping Method Code" to a default value each time a customer is created. Shipping Method Code pulls from another table so it appears as a dropdown/drilldown on the Customer card.
Is there a way to set one of the values in there as the default? Can I just set the "InitValue" property to whatever I want it to be and it'll match up automatically?
Thanks for any help!
Comments
"Shipping method code" := 'ABC'
also you should put this code at the place where the default value for Shipping method code is being pulled by Default values.
SB.
Then, in the OnInsert trigger of the Customer table, you add something like this:
That way, your users can enter the default code to use in a setup table, and they would not have to get you involved to update the C/AL code every time they feel like changing the default value. The validation of the field value would be taken care of the DBMS because of the table relation of the field.
It is generally not a good idea to hard code any values, either by setting an initvalue in a property or by writing lines of code. If you make it a habit of programming forms to manipulate data, you will at some point spend most of yuor time searching where the hell this code is that keeps messing up your data. Form events should only be used to program the appearance and behaviour of the form.
RIS Plus, LLC
you can do this - we have our InitValue set as "UPS" for shipping agent code
http://www.BiloBeauty.com
http://www.autismspeaks.org
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
RIS Plus, LLC
Yes, as you wrote: As long as the code value UPS is an existing value... but after that, it is problem... but it depend what you want to do with your application in the future. If you want to use it in another country or something... :-) Cheap now, costly after...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Sometime it will work out ( it probably will in this case) , but if you, for instance, change the init value of "Type" in Sales Line from Type::" " to Type::Item, you may encounter all sorts of problems with a coded SalesLine.INIT and subsequent processing, because the whole code was built on the base of Type::" ". Creating additional default values in the setup tables also has the advantage of informing other developers at a glance that something has been changed.
We use the InitValue in a few fields for a NEW customer that will ALWAYS be the same for our company (many other companies may differ)
Posting Groups, Costing Method, Shipping Agent, etc
It was necessary due to the fact that sometimes the person entering the new customer would occasionally leave them blank and cause all kinds of problems with E-ship & fast packing. So it was better to have them automatically fill in. Fields that can vary use the mandatory field solution discussed several times in this forum.
http://www.BiloBeauty.com
http://www.autismspeaks.org
Navision HQ themselves did it with Customer Templates, for example.
They can't be wrong, can they?...