Transaction Panel Sort Order

SOLVED

The default sort sequence on the Inventory Transaction tab is ascending Transaction Date.  Can the default be changed to descending?  Or, if that's not possible, can it be done with a user-defined script on the Panel post-load event and what would the code be?

  • +1
    verified answer

    I believe the default sort order is actually based on the IM_ItemTransactionHistory table's primary key in ascending order which is ItemCode+WarehouseCode+TransactionDate.

    I don't know of a way to customize the transactions listbox to have a default sort column and order via traditional Customizer methods but you can use a UI Post Load event script on version 2015+ attached to the Item Maintenance library's pTrans panel.


    If IsObject(oSession) Then
    If oScript.UIObj > 0 Then
    If InStr(UCase(oSession.AsObject(oScript.UIObj).GetFolderName()), UCase("pTrans")) > 0 Then
    oSession.AsObject(oScript.UIObj).SetControlProperty "LB_Transactions", "Sort", "-4"
    End If
    End If
    End If


    The script first checks that oSession has been set to a proper object handle by the script engine and then checks to make sure that the oScript.UIObj is greater than zero which indicates we can use that object handle to call the SetControlProperty method. The methods arguments are;

    1. Control Name (in this case, LB_Transactions).
    2. The Property Name (in this case, Sort).
    3. The Value to set the Property to (in this case -4, the "-" indicates descending order, the "4" indicates the column number. There is a hidden first column).

    Keep in mind however that any sage 100 activity that modifies the listbox's contents will reset the Sort property. This means change the Warehouse above the listbox, clicking the All button above the listbox, or changing the filter for the listbox via the Search button.

    What the script will do though is set the Sort property anytime you switch to the Transactions tab.

  • +1 in reply to David Speck
    verified answer

    Thanks very much for this.  I'll give it a try!

  • 0 in reply to David Speck

    Works perfectly!  Thanks for your help!