Skip to main content
Answer

Custom Field using StringList Instead of IntList

  • July 13, 2021
  • 6 replies
  • 1095 views

Forum|alt.badge.img

I tried to create an attribute and then a UDF for a custom field I need to add to the Contact form.  I created a custom project, I created the new field (as a string of length 10) and I added it to the Contacts form.  By Default, everything works fine.  It’s a string field and I am able to enter and save values.  However, I want to change it to a combo box so I can restrict the user’s entries.  In my custom project, I go to “customize” the attributes and I use the following:

[PXDBString(10)]
[PXStringList(new string[] {"N", "P", "Y"}, new string[] {"No", "Pending", "Yes"})]
[PXUIField(DisplayName="Status")]

It always gives me a TextEdit.  Am I missing a line of code?

In the past, I have created the new field as an Integer and used the following code:

[PXDBInt]
[PXIntList(new int[] {1, 2, 3}, new string[] {"No", "Pending", "Yes"})]
[PXUIField(DisplayName="Status")]

This works and I could do this but I’m trying to keep the values as string and not integers.

 

Best answer by Naveen Boga

Hi @PRapnikas  Code looks good, can you please also confirm that you have given the <PXDropdown> control in .aspx page ?

<px:PXDropDown ID="edStatus" runat="server" DataField="Status"> </px:PXDropDown>

6 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • July 13, 2021

Hi @PRapnikas  Code looks good, can you please also confirm that you have given the <PXDropdown> control in .aspx page ?

<px:PXDropDown ID="edStatus" runat="server" DataField="Status"> </px:PXDropDown>


Forum|alt.badge.img
  • Author
  • Freshman II
  • July 13, 2021

That might be the problem.  I am only adding the code I listed above.  I’m new to Acumatica and learning quickly, but I am not modifying any code directly.  Everything I do is through the UI.  Also, we are on a hosted solution.  If this is something I can do from the Project Editor, then please let me know where and I will try it.  


Forum|alt.badge.img
  • Author
  • Freshman II
  • July 13, 2021

Actually, I played around with this and was able to make the modification.  Worked great.  Thanks for the help.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • July 13, 2021

@PRapnikas  Great :) Thanks for sharing an update.


Forum|alt.badge.img
  • Author
  • Freshman II
  • July 13, 2021

A quick question.  Is it possible to make that combobox a multi-select?  If so, how would I do that?


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • July 13, 2021

yes @PRapnikas  We can do it.  Please find the sample code below.

[PXStringList(new string[] {"N", "P", "Y"}, new string[] {"No", "Pending", "Yes"}, MultiSelect =true)]