Solved

Conditionally Display Custom Field based on Order Type

  • 6 June 2023
  • 9 replies
  • 173 views

Userlevel 3
Badge

I have been able to add a custom field to SO301000. I am struggling with how to show/hide the custom field based on the Order Type field. I tried to create an event handler based on the RowSelected event. But, I failed. My edit hid the field always, and left the label visible always.

Can anyone point me in the right direction?

icon

Best answer by darylbowman 7 June 2023, 13:55

View original

9 replies

Badge +11

The best way to learn is to have someone pick apart your failed attempts 😁

Can you post the code you tried?

Badge +11

In the meantime, something like this should work, placed on the custom field’s attributes:

[PXUIVisible(typeof(Where<SOOrder.orderType.IsEqual<SOOrderTypeConstants.salesOrder>>))]

 

Userlevel 2
Badge +1

Hi rcreasy

In case you’re interested in a  low / no code method.

We sometimes use Conditions and then apply that to the fields “Hidden” property.  See the screenshot below for an example.

 

Userlevel 7
Badge +17

Hi, @rcreasy  The above code provided by Darylbowman should work. Add this PXUIVisible attribute to the DAC field.

 

[PXUIVisible(typeof(Where<SOOrder.orderType.IsEqual<SOOrderTypeConstants.salesOrder>>))]

 

As you mentioned, the RowSelected code did not work, can you please share the code here?

Userlevel 3
Badge

@darylbowman @Naveen Boga  Point taken regarding my code. I definitely should have ported it. However, I deleted it. (I haven’t figured out git in the Visual Studio environment yet. I am a vi guy and am new to VS)

 

In re-reading my post, I think I didn’t explain my need very well. I need to conditionally display my custom field only when a specific order type (“NC”) is selected.

Thanks for everyone’s patience with me as I learn.

Badge +11

If SOOrderTypeConstants doesn’t have the required value you need, you can define a constant of your own like this:

public class ncOrder : PX.Data.BQL.BqlString.Constant<ncOrder>
{
public ncOrder() : base("NC") { }
}

Then use ncOrder in the statement:

[PXUIVisible(typeof(Where<SOOrder.orderType.IsEqual<ncOrder>>))]

 

Userlevel 3
Badge

@darylbowman Brilliant! It works perfectly. Thanks for the help!

Do you mind pointing me to info or explaining:

 public ncOrder() : base("NC") { }

 

Badge +11

This is my understanding:

 

this defines the class ncOrder, which inherits the BqlString.Contant class

public class ncOrder : PX.Data.BQL.BqlString.Constant<ncOrder>
{

}

 

this overrides the base constructor with a new string value

public ncOrder() : base("NC") { }

 

This may not be entirely technically correct, but the result is a BQL constant from a string.

Userlevel 3
Badge

@darylbowman that makes sense, and helps a lot. Thank you!

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