Skip to main content
Answer

PXDefault default menu attribute

  • March 20, 2025
  • 3 replies
  • 94 views

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.

3 replies

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

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.


DipakNilkanth
Pro III
Forum|alt.badge.img+13

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
  • Jr Varsity II
  • March 20, 2025

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.

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. :)