Solved

Conditionally hiding a field on AM301000

  • 1 October 2022
  • 3 replies
  • 289 views

Userlevel 7
Badge +5

I’m trying to conditionally hide a column on the Labor screen (AM301000) and I can’t for the life of me figure out the code. 

protected void AMBatch_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (AMBatch)e.Row;

PXUIFieldAttribute.SetVisible<Objects.AM.AMMTran.laborRate>(Base.transactions.Cache, row, false);
}

However, that generates an error:

The entry form (ID: AM301000, title: Labor) cannot be automated. Unable to cast object of type 'PX.Objects.AM.AMBatch' to type 'PX.Objects.AM.AMMTran'.

This:

PXUIFieldAttribute.SetVisible<Objects.AM.AMMTran.laborRate>(cache, row, false);

Does nothing - the field remains visible.  I don’t think there is any workflow attached to the form.

I’ve tried to access the transactions view but it doesn’t seem to be part of Base.  I think that this form is pulling transactions through another layer of extensions.

What am I missing?

icon

Best answer by Django 1 October 2022, 22:52

View original

3 replies

Userlevel 3

Hi @ddunn ,

 

Maybe this post can be useful for you:

 


Regards,

Userlevel 7
Badge +5

I figured it out. I thought that I would need to pass the cache related to the AMMTran records instead of the batch. The Element Properties of the grid shows that the View Name is transactions but I couldn’t seem to access ‘transaction’ via code.

 

Within LaborEntry.cs there is only a passing reference to ‘transactions’ and the class for the Graph is:

public class LaborEntry : MoveEntryBase<Where<AMBatch.docType, Equal<AMDocType.labor>>>

Now, MoveEntryBase.cs does contain the ‘transactions’ view.

Within LaborEntry.cs did see this line:

public override PXSelectBase<AMMTran> LSSelectDataMember => LineSplittingExt.lsselect;

So, on a whim, I tried the following and it worked:

protected void AMBatch_RowSelected(PXCache cache, PXRowSelectedEventArgs e) //, PXRowSelected InvokeBaseHandler)      
{
PXUIFieldAttribute.SetVisible<Objects.AM.AMMTran.laborRate>(Base.LSSelectDataMember.Cache, null, false);
PXUIFieldAttribute.SetVisible<Objects.AM.AMMTran.extCost>(Base.LSSelectDataMember.Cache, null, false);
}

 

Userlevel 7
Badge

Thank you for sharing your solution with the community @ddunn!

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved