Skip to main content
Answer

Conditionally Display Custom Field based on Order Type

  • June 6, 2023
  • 9 replies
  • 380 views

rcreasy
Varsity I
Forum|alt.badge.img

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?

Best answer by darylbowman

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>>))]

 

9 replies

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

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

Can you post the code you tried?


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

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

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

 


Forum|alt.badge.img+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.

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • June 7, 2023

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?


rcreasy
Varsity I
Forum|alt.badge.img
  • Author
  • Varsity I
  • June 7, 2023

@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.


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

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>>))]

 


rcreasy
Varsity I
Forum|alt.badge.img
  • Author
  • Varsity I
  • June 7, 2023

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

Do you mind pointing me to info or explaining:

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

 


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

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.


rcreasy
Varsity I
Forum|alt.badge.img
  • Author
  • Varsity I
  • June 7, 2023

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