Skip to main content
Solved

How to extend Attribute field length


Forum|alt.badge.img

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.

Best answer by Naveen Boga

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) ;

 

View original
Did this topic help you find an answer to your question?

7 replies

Vignesh Ponnusamy
Acumatica Moderator
Forum|alt.badge.img+5

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,  


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 28 replies
  • October 10, 2023

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

 


Forum|alt.badge.img+9
  • Semi-Pro III
  • 229 replies
  • October 12, 2023

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


RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+4
  • Acumatica Moderator
  • 253 replies
  • October 12, 2023

@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:

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • Answer
  • October 13, 2023

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) ;

 


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 28 replies
  • October 16, 2023

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

Naveen Boga wrote:

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) ;

 

 


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 28 replies
  • October 23, 2023

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings