3

I am selecting multiple lines (ctrl/shift+click) from the grid on the Sales Order screen and want an action to have access to what was selected. How do I access the list of what's selected on the grid from the code behind?

Selected on sales Order grid

  • 1
    Did you find a solution? The normal Acumatica way to do this is to add an unbound field "Selected" as a checkbox (bool). The user selects the lines via the checkbox, and then you access that selection via MyView.Select where Selected == true. – Brian Stevens Mar 29 '21 at 13:44
  • I did not, I made a topic in their ideas forum. I was getting complaints from users about the check mark being too slow if they wanted to interact with a range of items, which is why i thought having access to the multi-select would be nice. – Smörgåsbord May 17 '21 at 13:40
  • 1
    Here is the idea on community.acumatica.com site: https://community.acumatica.com/ideas/access-to-multi-selected-items-from-pxgrid-in-actions-and-events-4959 – Dmitrii Naumov Jul 02 '21 at 16:59
  • 1
    @Smörgåsbord What I have done in the past to make the checkboxes easier is create another action that toggles Checked / unchecked and respects the filtering of the grid. I upvoted your idea though, much more efficient – Kyle Vanderstoep Jul 08 '21 at 14:08

1 Answers1

0

As stated, add the selected screen. First you would add a DAC extension to add the selected field, which is not a DB field.

    #region Selected 
    [PXBool]
    [PXUIField(DisplayName = "Selected")]
    public virtual bool? Selected { get; set; }
    public abstract class selected : PX.Data.BQL.BqlBool.Field<selected> { }
    #endregion

From there, you can add the selected field to your table in the UI. Also, ensure that commit changes is set on that field, or an action that you may call to query.

Finally, you can just run a foreach for the view, and check for the selected field you added:

        foreach (SOLine line in Base.Transactions.Select())
        {
            SOLineExt lineExt = line.GetExtension<SOLineExt>();
            if (line.Selected == true)
            {
                //execute code on the record
            }
        }
KRichardson
  • 990
  • 7
  • 12