Loading ...

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.

 

Be the first to rate this post

  • Currently 0.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5