Skip to main content
Solved

PXDefault default menu attribute


Forum|alt.badge.img

Hi all, I tried a low code customization to set a dropdown menu’s default value, and for some reason it’s not working. So I’m attempting to set the default via customized attribute like this:

[PXDBInt]

[PXIntList(new int[] {0, 1,}, new string[] {"No", "Yes"})]

[PXDefault[(0)]

[PXUIField(DisplayName="Mold or Part Texture?")]

I’ve tried setting the default to 0, to No (no quotes) and “No”, and none of them seem to work… I must be doing something wrong! :) Any help appreciated.

Best answer by Samvel Petrosov

It looks like you have extra comma in the first array in PXIntList.
I usually set the default value like this if the value is not a string.       

[PXDBInt]
[PXIntList(new int[] { 0, 1 }, new string[] { "No", "Yes" })]
[PXDefault(TypeCode.Int32, "0", PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Mold or Part Texture?")]

Please have in mind that the Default value only is applied to the record when it is being inserted/created or if it forced to run from the code.

So if you are testing this on some existing record, the default value will not be applied.

View original

3 replies

Samvel Petrosov
Jr Varsity II
Forum|alt.badge.img+5

It looks like you have extra comma in the first array in PXIntList.
I usually set the default value like this if the value is not a string.       

[PXDBInt]
[PXIntList(new int[] { 0, 1 }, new string[] { "No", "Yes" })]
[PXDefault(TypeCode.Int32, "0", PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Mold or Part Texture?")]

Please have in mind that the Default value only is applied to the record when it is being inserted/created or if it forced to run from the code.

So if you are testing this on some existing record, the default value will not be applied.


Nilkanth Dipak
Semi-Pro I
Forum|alt.badge.img+10

Hi ​@swartzfeger,

I believe you have added extra square bracket to your PXDefault attribute.

Replace [PXDefault[(0)] to [PXDefault(0)], It will deafults your value to No.

Hope, it helps!


Forum|alt.badge.img
  • Author
  • Freshman II
  • 172 replies
  • March 20, 2025
Samvel Petrosov wrote:

It looks like you have extra comma in the first array in PXIntList.
I usually set the default value like this if the value is not a string.       

[PXDBInt]
[PXIntList(new int[] { 0, 1 }, new string[] { "No", "Yes" })]
[PXDefault(TypeCode.Int32, "0", PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Mold or Part Texture?")]

Please have in mind that the Default value only is applied to the record when it is being inserted/created or if it forced to run from the code.

So if you are testing this on some existing record, the default value will not be applied.

Nilkanth Dipak wrote:

Hi ​@swartzfeger,

I believe you have added extra square bracket to your PXDefault attribute.

Replace [PXDefault[(0)] to [PXDefault(0)], It will deafults your value to No.

Hope, it helps!

Thank you both! Yes, I see the stray comma now! And Nilkanth thank you for pointing out the extra bracket. :)

With those changes I can actually use the low code default field… I need to learn to read better. :)


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