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