I have a dac extension of SOLine in which i have few fields. . Below is the code of DAC extension with two fields only but there are more similar fields.
Serializable]
PXCacheName("TSSOLineExt")]
public sealed class TSSOLineExt : PXCacheExtension<SOLine>
{
#region UsrOriginalEquipmentNbr
mPXDBString(15, IsUnicode = true, InputMask = "")]
PXSelector(typeof(TSRentalFleet.refNbr))]
fPXUIField(DisplayName = "Original Equipment Nbr")]
public string UsrOriginalEquipmentNbr { get; set; }
public abstract class usrOriginalEquipmentNbr : PX.Data.BQL.BqlString.Field<usrOriginalEquipmentNbr> { }
#endregion
#region UsrOriginalInventoryID
nStockItem(DisplayName = "Original Inventory ID")]
public Int32? UsrOriginalInventoryID { get; set; }
public abstract class usrOriginalInventoryID : PX.Data.BQL.BqlInt.Field<usrOriginalInventoryID> { }
#endregion
}
Now I have to hide this field when SOOrder.OrderType = ‘HC’ or ‘QT’. For WorkOrder it will be visible. These order types are coming from custom preferences screen. Below is my code for hiding columns.
protected void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected handler)
{
handler?.Invoke(cache, e);
SOLine row = e.Row as SOLine;
if (row == null) return;
InventoryItem Inv = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, row.InventoryID);
TSInventoryItemExt Invext = Inv.GetExtension<TSInventoryItemExt>();
SOOrder doc = Base.Document.Current;
if (doc == null) return;
TSRentalPreference item = PXSelect<TSRentalPreference>.Select(Base);
TSSOLineExt rowexts = row.GetExtension<TSSOLineExt>();
if (item != null)
{
PXUIFieldAttribute.SetVisible<SOLine.pOCreate>(cache, null,false);
PXUIFieldAttribute.SetVisible<TSSOLineExt.usrOriginalInventoryID>(cache, row, doc.OrderType == item.RentalWorkOrder);
}
}
I even tried to use PXUiVisible attribute and Visible=true of PXUiField. But still the column was visible. Please help.