Hi Everyone,
Extending of field length in Acumatica is not a trivial task, so here I want to publish guidance on how I usually do that.
To extend field we need to do 2 things:
- Extend allowed length in DAC attribute
- Extend length of Database Column
Welcome under the cut for more details
Extend Field in the DAC
Here you need to find PXDBStringAttribute and redefine it. Allowed field length is passed in constructor so unfortunately you cannot easily change it with PXCustomizeBaseAttribute. In the end you have 2 ways:
- Redefine all attributes –
- [PXDBString(200, IsUnicode = true)]
- [PXUIField(DisplayName = “Address Line 1”, Visibility = PXUIVisibility.SelectorVisible)]
- [PXMassMergableField]
- Remove Specific attribute and add if again –
- [PXRemoveBaseAttribute(typeof(PXDBStringAttribute))]
- [PXDBString(200, IsUnicode = true)]
I think second way is better as here you have less changes in the base code.
Extend DB column <
The biggest complexity here is that Acumatica Customization browser not yet allow to extend DB field, so even if you add column with same name and longer lengh it will not be extended in DB as field has been created already.
Correct way will be to write an update script against DB:
alter table Address alter column AddressLine1 Nvarchar(200) null
That is it. Now you can publish customization and use extended field.
Few Important notes about fields length:
- Acumatica upgrade procedure will not shrink database column if its length is longer, but it will extend it if the length is shorter than defined in Acumatica schema.
- Acumatica Snapshots cannot detect extended fields so you have to apply customization before you can import snapshot with extended field to new instance.
- Field Update script can be executed and on MS SQL and on MySQL the same way.
- In case you have depended or copied fields you will need to extend their length as well. For example Billing and Shipping address is copied from customer to special tables in AR/AP/PO/SO and other modules, so you have to extend other AddressLine1 as well. I recommend to search for address line in whole database. Do the same for DACs.
Have a nice Development!
Sergey:
When following this guide, I am not able to extend the UOM field length in Acumatica due to a very strange error.
Please see this link: https://community.acumatica.com/customizations-147/extend-field-length-7612?postid=25324#post25324 for what I’ve tried.
Hi Freeman, it is a bit hard to say what happens without a debugger… Could you please create a support ticket so our support team can check your code?