Solved

How to extend Attribute field length

  • 10 October 2023
  • 7 replies
  • 270 views

Userlevel 2
Badge

Default length for value field is 255 in CSANSWERS table. We are getting cast error after we extend DAC to 500. Since the field is shared with different control types. So what could I do to extent the field length to allow longer text for Text type attribute? Thanks.

icon

Best answer by Naveen Boga 13 October 2023, 05:37

View original

7 replies

Userlevel 7
Badge +4

Hi @woodyg84,

Can you share details on how you updated the length of the attributes and steps to reproduce the error, error stack?

If possible, share a customization using which we could reproduce the issue. Thanks,  

Userlevel 2
Badge

That is the similar steps I took, and the same error I got.

 

Userlevel 7
Badge +10

Hi @woodyg84 ,

 

To extend the field length for a value field in the CSANSWERS table shared by different control types in Acumatica Customization Project:

  1. Extend the DAC Field: Modify the DAC extension code to increase the field length as needed.

  2. Database Schema Changes: Update the database schema to reflect the new field length. This can be done via SQL script or Acumatica's Database Schema Editor.

  3. Redeploy Your Customization: Apply the DAC extension and schema changes to your Acumatica instance.

Hope it helps.!

 

Regards,

Sweta

Userlevel 7
Badge +4

@woodyg84  as @Vignesh Ponnusamy mentioned please share additional details like build/version number, steps you are taking to extend field length and error message.

Here’s a general way:

 

Userlevel 7
Badge +17

Hi @woodyg84  By default, Acumatica will allow us to enter 255 characters and if we wanted to make the field to allow unlimited characters we need to make the changes at the code level and database level to increase the field length. Please find the code and SQL script for the same.

 

  public class InventoryItemMaint_Extension : PXGraphExtension<PX.Objects.IN.InventoryItemMaint>
{

[PXAttributeValue]
[PXUIField(DisplayName = "Value")]
//[CSAttributeValueValidation(typeof(CSAnswers.attributeID))]
[PXPersonalDataFieldAttribute.Value]
public void CSAnswers_Value_CacheAttached(PXCache sender)
{
}
#endregion
internal class PXAttributeValueAttribute : PXDBStringAttribute
{
public PXAttributeValueAttribute() : base()
{
IsUnicode = true;
}
public override void FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
{
if (e.NewValue is DateTime)
e.NewValue = Convert.ToString(e.NewValue, CultureInfo.InvariantCulture);
base.FieldUpdating(sender, e);
}
}

}
ALTER TABLE CSAnswers ALTER COLUMN Value [nvarchar](Max) ;

 

Userlevel 2
Badge

I thought about override field event, but wouldn’t that mean that I need to do this for all screens that contains attribute function? 

Hi @woodyg84  By default, Acumatica will allow us to enter 255 characters and if we wanted to make the field to allow unlimited characters we need to make the changes at the code level and database level to increase the field length. Please find the code and SQL script for the same.

 

  public class InventoryItemMaint_Extension : PXGraphExtension<PX.Objects.IN.InventoryItemMaint>
{

[PXAttributeValue]
[PXUIField(DisplayName = "Value")]
//[CSAttributeValueValidation(typeof(CSAnswers.attributeID))]
[PXPersonalDataFieldAttribute.Value]
public void CSAnswers_Value_CacheAttached(PXCache sender)
{
}
#endregion
internal class PXAttributeValueAttribute : PXDBStringAttribute
{
public PXAttributeValueAttribute() : base()
{
IsUnicode = true;
}
public override void FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
{
if (e.NewValue is DateTime)
e.NewValue = Convert.ToString(e.NewValue, CultureInfo.InvariantCulture);
base.FieldUpdating(sender, e);
}
}

}
ALTER TABLE CSAnswers ALTER COLUMN Value [nvarchar](Max) ;

 

 

Userlevel 2
Badge

@Naveen Boga  thanks a lot for the code example, so do I need to do this to other screens with attribute function?

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved