Skip to main content

Disable a field in UI but enable for Import Scenarios

  • September 18, 2024
  • 1 reply
  • 99 views

darylbowman
Captain II
Forum|alt.badge.img+15

Since Import Scenarios usually behave exactly as using the UI would, fields disabled in the UI are normally not able to be imported to.

 

This custom attribute will allow you to specify a field to be disabled for the UI but still allow importing:

public class DXEnableForImportAttribute : PXEventSubscriberAttribute, IPXRowSelectedSubscriber
{
public DXEnableForImportAttribute() :
base()
{ }

public void RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
PXUIFieldAttribute.SetEnabled(cache, e.Row, _FieldName, cache.Graph.IsImport);
}
}

Then use it:

#region UsrCustomField
[PXDBString(15, IsUnicode = true)]
[DXEnableForImport] // here
[PXUIField(DisplayName = "Custom Field")]
public virtual string UsrCustomField { get; set; }
public abstract class usrCustomField : BqlString.Field<usrCustomField> { }
#endregion

 

1 reply

Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • September 18, 2024

Thank you for sharing this tip with the community @darylbowman!