Skip to main content
Solved

Conditionally hiding a field on AM301000


Forum|alt.badge.img+6

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?

Best answer by Django

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);
}

 

View original
Did this topic help you find an answer to your question?

3 replies

deybanperez83
Jr Varsity III
  • Jr Varsity III
  • 13 replies
  • October 1, 2022

Hi @ddunn ,

 

Maybe this post can be useful for you:

 


Regards,


Forum|alt.badge.img+6
  • Author
  • Captain II
  • 569 replies
  • Answer
  • October 1, 2022

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);
}

 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2769 replies
  • October 2, 2022

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

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings