Venky
Venky

Reputation: 11

Acumatica - Cases Status Comboxbox

we have added some additional status options to Status field in cases screen using automation steps and this is working as expected. Now our requirement is to show the status options in alphabetical order sort by ascending way. Can some one please suggest us how to achieve this.

We are in Acumatica 2019 R2

 public class SelectableDataTypes : PXStringListAttribute
    {
        public string[] AllowedLabels = new string[]
        {
            "A","B","C"
        };

        public string[] AllowedValues = new string[]
        {
            "ValueA","ValueB","ValueC"            
        };
    }

    protected virtual void CRCase_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected BaseEvent)
        {
            BaseEvent?.Invoke(sender, e);

            CRCase doc = e.Row as CRCase;

            if (doc == null)
                return;

            PXStringListAttribute.SetList<CRCase.status>(Base.Case.Cache, null, new SelectableDataTypes().AllowedValues, new SelectableDataTypes().AllowedLabels);
        }

Upvotes: 1

Views: 86

Answers (1)

Brian Stevens
Brian Stevens

Reputation: 1941

I'm not sure if there is a way to just "sort", but I have never tried to do so. Also worth noting that this method requires programming a list change rather than using Automation Steps, so it is not quite as easy to add entries to your list but is much more controllable.

You can redefine the options in the order you want them displayed much the same that I make dynamic lists if that suits your purpose. This example assumes you have Messages defined for each label and a class with each value defined in a list.

Make a class that inherits from PXStringListAttribute and define a string array for AllowedLabels and one for AllowedValues. Include the options you want, sorted in the order you want. For this example, we will assume that this is defined in a class called MySelectableData.

public class SelectableDataTypes : PXStringListAttribute
{

    public string[] AllowedLabels = new string[]
    {
            Messages.FieldLabelA,
            Messages.FieldLabelB,
            Messages.FieldLabelC,
            Messages.FieldLabelD,
            Messages.FieldLabelE,
            Messages.FieldLabelF,
    };

    public string[] AllowedValues = new string[]
    {
            DataValues.ValueA,
            DataValues.ValueB,
            DataValues.ValueC,
            DataValues.ValueD,
            DataValues.ValueE,
            DataValues.ValueF,
    };
}

Again, since your goal is to have the selection sorted, be sure to list them in the sorted order.

If the list is dynamic, place the following (with logic to change between lists) in the RowSelected event. If it is static for the page (more likely in the case you describe) then place it in the Initialize method for the page.

PXStringListAttribute.SetList<MyDAC.myField>(
    MyView.Cache,
    null,
    new MySelectableData.SelectableDataTypes().AllowedValues,
    new MySelectableData.SelectableDataTypes().AllowedLabels
);

SetList on PXStringListAttribute will allow you to override the list as shown here by substituting your custom options in place of the previously defined options.

Upvotes: 1

Related Questions