Skip to main content
Answer

How to Update ComboBox Values Real-Time in Acumatica?

  • May 29, 2025
  • 6 replies
  • 113 views

Forum|alt.badge.img

Hello Acumatica Community,

I'm working on a custom integration in the Sales Order Entry screen and facing challenges with dynamically updating the values in a custom ComboBox field (usrAISQuoteCategory) within the SOLine table. Specifically, I want the ComboBox to reflect the correct list of values in real-time when the InventoryID field changes.

 

Here's a summary of what I'm trying to achieve:

  • When InventoryID is updated, the ComboBox should fetch and display descriptions from CSAttributeDetail based on the attribute ID "QUOTECTGRY".
  • I'm using the PXStringListAttribute.SetList method within the SOLine_InventoryID_FieldUpdated event handler, but the UI requires a manual refresh to update the ComboBox values.
  • I've attempted using SetValueExt to trigger UI refreshes, but the real-time display update isn't working as expected.

 

Here’s a snippet of my current implementation:
using PX.Data;
using PX.Objects.SO;
using PX.Objects.IN;
using PX.SM;
using System;
using System.Collections;
using System.Collections.Generic;
using PX.Objects.CS;

namespace AISQuoteCategory2023R2V2
{
public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
{
#region Event Handlers
public virtual void SOLine_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e, PXFieldUpdated baseMethod)
{
baseMethod?.Invoke(sender, e);

SOLine row = (SOLine)e.Row;

if (row == null)
{
return;
}

if(row.InventoryID != null)
{
InventoryItem inventory = PXSelect<InventoryItem,
Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, row.InventoryID);

if(inventory != null)
{
CSAnswers answers = PXSelect<CSAnswers,
Where<CSAnswers.refNoteID, Equal<Required<CSAnswers.refNoteID>>,
And<CSAnswers.attributeID, Equal<Required<CSAnswers.attributeID>>>>>.Select(Base, inventory.NoteID, "QUOTECTGRY");

if (answers != null)
{
row.GetExtension<SOLineExtension>().UsrAISQuoteCategory = answers.Value;
}
}
}
}
public virtual void SOLine_UsrAISQuoteCategory_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
{
SOLine row = (SOLine)e.Row;

if (row != null)
{
PXResultset<CSAttributeDetail> attribDetailRes = PXSelect<CSAttributeDetail,
Where<CSAttributeDetail.attributeID, Equal<Required<CSAttribute.attributeID>>>>.Select(Base, "QUOTECTGRY");

List<string> values = new List<string>();

foreach (CSAttributeDetail item in attribDetailRes)
{
values.Add(item.Description);
}

PXStringListAttribute.SetList<SOLineExtension.usrAISQuoteCategory>(sender, null, values.ToArray(), values.ToArray());
}
}

#endregion
}
}


 

Any tips on addressing this issue with real-time updates or best practices for dynamic ComboBoxes in Acumatica would be highly appreciated!

Thank you!

Best answer by melvinc

 

6 replies

jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • May 30, 2025

Hi ​@melvinc ,

Could you please try the following?

protected void SOLine_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
    var row = (SOLine)e.Row;
    if (row == null) return;

    // Fetch attribute details for "QUOTECTGRY"
    var details = PXSelect<CSAttributeDetail,
        Where<CSAttributeDetail.attributeID, Equal<Required<CSAttributeDetail.attributeID>>>>
        .Select(sender.Graph, "QUOTECTGRY")
        .RowCast<CSAttributeDetail>()
        .ToList();

    var values = details.Select(d => d.ValueID).ToArray();
    var labels = details.Select(d => d.Description).ToArray();

    // Dynamically set the list for the current row
    PXStringListAttribute.SetList<SOLine.usrAISQuoteCategory>(sender, row, values, labels);

    // Optionally reset the value if needed
    sender.SetValueExt<SOLine.usrAISQuoteCategory>(row, null);
}
 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • June 2, 2025

​Hi @jinin thank you for you help, I tried this same thing happen its not showing the options real time, so I decided to use selector instead.


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • Answer
  • June 2, 2025

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • June 2, 2025

I think dropdowns behave differently on websockets so it only works if you put static data.


darylbowman
Captain II
Forum|alt.badge.img+15

It is possible to change dropdown options dynamically. It may need to be done in the RowSelected event handler. Another option is to craft a FieldSelecting event handler:

protected virtual void _(Events.FieldSelecting<SOLine, SOLineExt.usrAISQuoteCategory> e)
{
SOLine row = e.Row;
if (row is null) return;

// Fetch attribute details for "QUOTECTGRY"
var details = PXSelect<CSAttributeDetail,
Where<CSAttributeDetail.attributeID, Equal<Required<CSAttributeDetail.attributeID>>>>
.Select(e.Cache.Graph, "QUOTECTGRY")
.RowCast<CSAttributeDetail>()
.ToList();

var values = details.Select(d => d.ValueID).ToArray();
var labels = details.Select(d => d.Description).ToArray();

e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 10, true, typeof(CSAttributeDetail.attributeID).Name, false, -1, string.Empty, keys?.ToArray(), values?.ToArray(), false, null);
((PXStringState)e.ReturnState).MultiSelect = false;
}

If you have a selector working, that’s probably just as good.


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • June 2, 2025

Hi ​@darylbowman thank you so much for this. I think selector is good for now.