Skip to main content
Answer

Unable to hide SOLine DAC extension column based on condition

  • May 10, 2024
  • 16 replies
  • 197 views

amitr70
Semi-Pro I
Forum|alt.badge.img

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
[PXDBString(15, IsUnicode = true, InputMask = "")]
[PXSelector(typeof(TSRentalFleet.refNbr))]
[PXUIField(DisplayName = "Original Equipment Nbr")]
public string UsrOriginalEquipmentNbr { get; set; }
public abstract class usrOriginalEquipmentNbr : PX.Data.BQL.BqlString.Field<usrOriginalEquipmentNbr> { }
#endregion

#region UsrOriginalInventoryID
[StockItem(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.

Best answer by darylbowman

This successfully hides ‘Mark for PO’ in 24 R1:

protected virtual void _(Events.RowSelected<SOLine> e)
{
SOLine row = e.Row;

// Must appear before ``if (row is null) return;``
PXUIFieldAttribute.SetVisible<SOLine.pOCreate>(e.Cache, row, false);

if (row is null) return;
}

 

16 replies

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

I’m assuming the second code snippet is from a graph extension of SOOrderEntry.

You’re using the RowSelected event of SOLine to do the hiding. Have you tried instead to use SOOrder?

If you think about it, even if this code did work, what would your logic do if you had two lines, one with a matching order type and one without? Would it show or hide?

Also, have you tried setting the value manually to false, just to see if the event is working properly?


Vignesh Ponnusamy
Acumatica Moderator
Forum|alt.badge.img+5

@amitr70,

You can also refer the example in the following thread,

 


amitr70
Semi-Pro I
Forum|alt.badge.img
  • Author
  • Semi-Pro I
  • May 11, 2024

@darylbowman

I’m assuming the second code snippet is from a graph extension of SOOrderEntry. 

Yes its is a part of SoOrderEntry

Have you tried instead to use SOOrder?

Yes 

If you think about it, even if this code did work, what would your logic do if you had two lines, one with a matching order type and one without? Would it show or hide?

If pretty simple actually. IF SOOrderType == RentalWorkOder then only these two fields willl be visible otherwise not. Conditions are already there in the code and debugger/control is moving perfectly fine except hiding the columns at the end of execution of code.

have you tried setting the value manually to false, just to see if the event is working properly?

Yes

I tried these as well

  1. removing all references from code and simply setting PXUIField visible = false --No effect still visible
  2. Used attribute
      [PXUIVisible(typeof(Where<SOOrder.orderType.FromCurrent , Equal<TSRentalPreference.rentalSOType>>))]

amitr70
Semi-Pro I
Forum|alt.badge.img
  • Author
  • Semi-Pro I
  • May 11, 2024

@Viaanisary  Indeed this was the first article that I referred to. Also my control has commit changes = true. But still no success.

I tried these versions of code

  1. PXUIFieldAttribute.SetVisible<SOLine.pOCreate>(cache, null,false); -- this too not hiding base field. Assuming that the problem is with my custom dac. But I was wrong, base fields are also not getting hide. From SOOrder DAC , I am able to hide SOOrder Ext DAC field.
  2. PXUIFieldAttribute.SetVisible<SOLine.pOCreate>(cache, row,false);
  3. PXUIFieldAttribute.SetVisible<SOLine.pOCreate>(Base.Transactions.Cache, null,false);
  4. PXUIFieldAttribute.SetVisible<SOLine.pOCreate>(Base.Transactions.Cache, row,false);
  5. PXUIFieldAttribute.SetVisibility<SOLine.pOCreate>(cache, row,
    PXUIVisibility.InVisible
    );

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

Could you share your customization package?


amitr70
Semi-Pro I
Forum|alt.badge.img
  • Author
  • Semi-Pro I
  • May 11, 2024

@darylbowman I am afraid I can't because of organizational policies, The package is a complete customization  where we are implementing a completely new process. Can you help me with the points/places  that  you want to inspect in the package?


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

Well, I was hoping to hook up a debugger and see what's being hit. I understand, but I can't be much help otherwise.


amitr70
Semi-Pro I
Forum|alt.badge.img
  • Author
  • Semi-Pro I
  • May 11, 2024

@darylbowman Can you help me with the way by which i can trace the line of codes impacting a particular field or variable in acumatica?


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

I'm not sure I completely understand the question. If you're familiar with debugging, I would suggest placing a breakpoint in the RowSelected event before your code and see if it gets hit.


amitr70
Semi-Pro I
Forum|alt.badge.img
  • Author
  • Semi-Pro I
  • May 11, 2024

@darylbowman Yes, indeed breakpoint is hitting in both SoOrder / SOline rowselected event of the core package and PXUIFieldAttribute.SetVisible codes are also getting executed. What I meant to say is that , i wanted to know if theres any way i can get to know about the execution of rowselected events from other packages as well. Because SOline SOOrder rowselcted event is a common event and  i have almost 8-10 different packages using SO301000 screen with the same DAC ..


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

Aside from telling you to read the source code, I don’t really have any great resources to point to, no.


amitr70
Semi-Pro I
Forum|alt.badge.img
  • Author
  • Semi-Pro I
  • May 14, 2024

@darylbowman  FYI, I even tried to create afresh customization on that customization package on SOLine rowselected event to hide show the fields assuming there might be some issue in original DAC. But still no success. 


Zoltan Febert
Jr Varsity I
Forum|alt.badge.img+3

@amitr70 Did you try to unpublish everything but your fresh customziation package with these two new columns and the rowselected event?


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

This successfully hides ‘Mark for PO’ in 24 R1:

protected virtual void _(Events.RowSelected<SOLine> e)
{
SOLine row = e.Row;

// Must appear before ``if (row is null) return;``
PXUIFieldAttribute.SetVisible<SOLine.pOCreate>(e.Cache, row, false);

if (row is null) return;
}

 


amitr70
Semi-Pro I
Forum|alt.badge.img
  • Author
  • Semi-Pro I
  • May 15, 2024

@Zoltan Febert Yes. I unpublished all packages and kept only dependent packages. Two packages actually. And in those two packages SOLine rowselected events arent used. Only DAC’s references are  there.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • July 1, 2024

Hi @amitr70 were you able to find a solution? Thank you!