Multiselect Combo Box

Hi All,

Today I want to discuss with you one short topic – how to implement Combo box with multiple options for select.

As an example I want to use scenario when we need to have a department associated with each particular customer. We have fixed and predefined number of departments so we do not want to configure them. Plus each customer can be associated with multiple departments, so we need to have a multiple options simultaneously.
Based on provided requirements, we can find that Combo Box (Drop Down control) is the best option here.

Acumatica Multiselect Combo Box

To do this I will use Acumatica customization engine. Lets go there and do it step by step:

  1. Go to Customization Projects and create new Project (You also can open existing one)
  2. Open Customization Browser
  3. Add screen to customization (In my example it is Customers)
  4. Open panel where you want to add new field (In my case it is Financial settings near to Customer Class field)
  5. Select a field and use “Create New Field” command to create a new field
  6. Provide settings for new field. It should be text field with some length bigger than total length of all values + number of values. This is because Acumatica will store values in database as a combined string – like “Value1,Value2,Value5”. Make sure that your field can store all possible values.
  7. Acumatica Add Custom Field
  8. Than you need to correct attributes, so lets go to Data Access classes and select you class and field.
  9. Attribute definition – [PXStringList(new string[] { “D”, “C”, “T”, “I” }, new string[] { “Development”, “Consulting”, “Training”, “Implementation” }, MultiSelect = true)] – Please note that there is one additional parameter “MultiSelect = true” that advises Acumatica to store multiple values in this field.
  10. Acumatica Custom Field Attributes
  11. Validate and publish this customization project. It is required to create a database field and all required support classes. Only after publishing you can continue with creating a field.
  12. Use “Create Controls” button to create a field. Use drag and drop to adjust field position. Please make sure that your field had type “ComboBox”.
  13. Set MultiSelect property to True on user interface control. This will set correct behavior for user interface.
  14. Acumatica Custom Field Control Properties
  15. Publish customization once again.
  16. Done. Do not forget to test it.

This will allow you to have multiple values at once. All values will be in the same DAC field. If you need you can use String.Split(…) to separate each selected field.
In the database you can see how Acumatica stores it.

Acumatica Custom Field Database Column

Have a nice Customization!

12 Replies to “Multiselect Combo Box”

  1. I wanted make the Mutiselect Field to Mandatory,on save it is validating and throwing the exception but the Manadatory symbol is not showing in the UI

    Here is the Code

    [PXDBString(250, IsUnicode = true)]
    [PXUIField(DisplayName = “Mapped Warehoueses”,Required =true)]
    [KNFNWarehousePrefetch()]
    [PXDefault()]
    public virtual string MappedWarehoueses { get; set; }
    public abstract class mappedWarehoueses : IBqlField { }

    Aspx:

    1. There may be several reasons for that, hard to say without code checking.
      I recommend you to check CacheAttached handles, Extensions and Events. It is possible that logic is overwritten in some of them.
      If that does not help you can create a FieldSelecting event and check what is returned from there. FieldsState contains what should be passed to the UI.

  2. Cosmin,

    Unfortunately that is not something out of the box…
    You may need to play around with customization and thow an error on FieldVerifying event if user has changes something that is forbidden.
    On you can just return value back instead of error.

    Hope it helps.

  3. Hi, can I disabled one of the options?

    For exemple: there are checked 3 options but the current user can edit only 3 from them.

    Or as a work arround to display all selected options inside text box and the drop list to show only editable options.

    My practical case is that the Admin is checking one box and the users can check the others but they can not uncheck the Admin selection.

  4. Dear Sergey,

    this is code on PXGraph ,class px graph to retrieve data from the database into the combobox


    public class StatusMultiStringListAttribute : PXStringListAttribute
    {
    public StatusMultiStringListAttribute() : base()
    {
    PXResultset rslt = PXSelect.Select(new PXGraph());
    List values = new List();
    List labels = new List();
    foreach (PXResult item in rslt)
    {
    BSMTStatus e = (BSMTStatus)item;
    values.Add(e.StatusID);
    labels.Add(e.Description);
    }

    this._AllowedValues = values.ToArray();
    this._AllowedLabels = labels.ToArray();
    MultiSelect = true;
    }
    }

    and this is code in DAC Combobox multiselect

    protected string _Status;
    [PXDBString(20, IsFixed =true)]
    [PXDefault]
    [PXUIField(DisplayName = "Status")]
    [StatusStringList]
    public virtual string Status
    {
    get
    {
    return this._Status;
    }
    set
    {
    this._Status = value;
    }
    }

  5. Dear Aditya,

    To be able to help you, i need to review your customization code.
    Could you please create an support ticket and provide code snippet?
    Acumatica team will review it as soon as possible.

  6. why when I save data to a database derived from multiselect combobox, the stored data is not everything
    for example, suppose I store the data of 3 pick in the combobox that is stored in the database is only 2, and if I save 2 data stored only one, please help
    thank you

  7. HI Gabriel,

    Actually I have over-configured it. Just used to do it many times before 😉
    I have checked, multiselect works without setting property on the control, so this step can be excluded.

Leave a Reply

Your email address will not be published. Required fields are marked *