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