How to modify PXIntList dynamically in Acumatica

Hello everybody,

today I want to leave a short code sample on how to modify PXIntList or dropdown list in Acumatica. Below goes code sample of it:

protected virtual void _(Events.RowSelected<CROpportunity> e)
{
    if (e.Row == null)
        return;
    var opportunityExtension = e.Row.GetExtension<CROpportunityExt>();
 
    if (opportunityExtension.UsrProduct == 0)
    {
        var listInts = new List<int>();
        var listStrings = new List<String>();
 
        listInts.Add(0);
        listInts.Add(1);
        listInts.Add(2);
 
        listStrings.Add("String 1");
        listStrings.Add("String 2");
        listStrings.Add("String 3");
 
        PXIntListAttribute.SetList<CROpportunityExt.usrProposition>(e.Cache, e.Row, listInts.ToArray(), listStrings.ToArray());
    }
 
    if (opportunityExtension.UsrProduct == 1)
    {
        var listInts = new List<int>();
        var listStrings = new List<String>();
 
        listInts.Add(0);
        listInts.Add(3);
        listInts.Add(5);
 
        listStrings.Add("String 2");
        listStrings.Add("String 3");
        listStrings.Add("String 4");
 
        PXIntListAttribute.SetList<CROpportunityExt.usrProposition>(e.Cache, e.Row, listInts.ToArray(), listStrings.ToArray());
    }
}

This code sample has two most important parts: 

  1. RowSelected ( declared over new syntax )
  2. PXIntListAttribute.SetList<CROpportunityExt.usrProposition> call

With usage of those two principles you can easily get modifiable collection accoding to necessary conditions in your code.

2 Comments

  • Bhavya said

    Hi Yuri,

    As mentioned above, i have added code to generate the values dynamically but how wil you design the DAC and aspx page for this dynamic list field. Could you please share that as well.

    Because, i have an issue when i am using this dynamic field into GI screen. the issue is value is not visible.

  • docotor said

    Hi Bhavia, for GI I would rather make PXIntList which has all possible combinations. Reason for that is that GI is read only, and it would be suffice for displaying values to end user, and mentioned about approach will modify behavior on run time on your machine

Add a Comment