Skip to main content
Solved

Implementing a Custom Data Type in Acumatica Data Provider

  • February 10, 2025
  • 2 replies
  • 134 views

Hello Community,

I am working on a customization in Acumatica where I need to implement a new data type in Acumatica Data Provider for text files (.txt).

Does anyone have experience with this or an idea of the approach? Any guidance, or documentation references would be greatly appreciated.

Thank you!

Best answer by Ankita Tayana

Hi kviranga38

To implement a custom text file data type in Acumatica's Data Provider, you can create a custom attribute inheriting from PXDBBinaryAttribute.

 

public class TextFileFieldAttribute : PXDBBinaryAttribute
{
public TextFileFieldAttribute() : base() { }

public override void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
{
base.FieldSelecting(sender, e);
if (e.Row == null) return;

var value = sender.GetValue(e.Row, _FieldName) as byte[];
if (value != null)
{
e.ReturnValue = Encoding.UTF8.GetString(value);
}
}

public override void FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
{
if (e.NewValue is string textContent)
{
e.NewValue = Encoding.UTF8.GetBytes(textContent);
}
base.FieldUpdating(sender, e);
}
}

Usage in your DAC:
[TextFile]
[PXUIField(DisplayName = "Text Content")]
public virtual byte[] TextContent { get; set; }
public abstract class textContent : IBqlField { }

Hope this helps

2 replies

Forum|alt.badge.img+5
  • Jr Varsity I
  • February 10, 2025

Forum|alt.badge.img+5
  • Jr Varsity I
  • Answer
  • February 10, 2025

Hi kviranga38

To implement a custom text file data type in Acumatica's Data Provider, you can create a custom attribute inheriting from PXDBBinaryAttribute.

 

public class TextFileFieldAttribute : PXDBBinaryAttribute
{
public TextFileFieldAttribute() : base() { }

public override void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
{
base.FieldSelecting(sender, e);
if (e.Row == null) return;

var value = sender.GetValue(e.Row, _FieldName) as byte[];
if (value != null)
{
e.ReturnValue = Encoding.UTF8.GetString(value);
}
}

public override void FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
{
if (e.NewValue is string textContent)
{
e.NewValue = Encoding.UTF8.GetBytes(textContent);
}
base.FieldUpdating(sender, e);
}
}

Usage in your DAC:
[TextFile]
[PXUIField(DisplayName = "Text Content")]
public virtual byte[] TextContent { get; set; }
public abstract class textContent : IBqlField { }

Hope this helps