Skip to main content
Answer

How to create a combo box for a decimal UDF column

  • January 19, 2024
  • 2 replies
  • 152 views

Forum|alt.badge.img

I created a UDF called UsrFTEV as a Decimal (2,2) column. (see screenshot below)
What I want to do is make this a Combo Box selection so that a user can only select the values either “1” or “.5”
For calculation reasons no other value should be allowed in that column.  However, I cannot figure out how to do that with a Decimal defined number.  I have done this very easily with Int and String values, but what should I do in the DAC definition?
[PXDBDecimal]
[PXUIField(DisplayName="FTEv")]

For Int column field this would be something like below
[PXIntList(new int[] {0,1}, new string[] {“0”,”1”})]

For a decimal number what is that command for a list?  And how can I change “NumberEdit” to “Combobox”? When I select “ComboBox” from the screen form data fields and Save, it reverts back to “NumberEdit”

 

 

 

Best answer by Sagar Greytrix

Hi @NetAdmin42 ,

Could you please try below code snippet?

 #region Usrtest1
[PXDBString(4)]
[PXUIField(DisplayName="test1")]
[PXStringList(new string[] {"1.00", "0.5"}, new string[] {"1.00", "0.5"})]

public virtual string Usrtest1 { get; set; }
public abstract class usrtest1 : PX.Data.BQL.BqlString.Field<usrtest1> { }
#endregion

I have replaced datatype Decimal to String and added PXStringList attribute. It will converts cotrol type to ComboBox.

Above code will allow you to select the values which are declared in PXStringList attribute.

Hope, it helps!

Regards,

Sagar, Greytrix

2 replies

Forum|alt.badge.img
  • Author
  • Semi-Pro II
  • January 19, 2024

BTW, I did try using this and it did not quite work for me.  Would not let me enter a 1.0

 

[PXDBDecimal]
[PXDecimalList( new string[] {"0.5","1.00"}, new string[] {"0.5","1.00"})]
[PXUIField(DisplayName="FTEv")]

 


Sagar Greytrix
Captain II
Forum|alt.badge.img+3
  • Captain II
  • Answer
  • February 7, 2024

Hi @NetAdmin42 ,

Could you please try below code snippet?

 #region Usrtest1
[PXDBString(4)]
[PXUIField(DisplayName="test1")]
[PXStringList(new string[] {"1.00", "0.5"}, new string[] {"1.00", "0.5"})]

public virtual string Usrtest1 { get; set; }
public abstract class usrtest1 : PX.Data.BQL.BqlString.Field<usrtest1> { }
#endregion

I have replaced datatype Decimal to String and added PXStringList attribute. It will converts cotrol type to ComboBox.

Above code will allow you to select the values which are declared in PXStringList attribute.

Hope, it helps!

Regards,

Sagar, Greytrix