SOH Transaction Detail. Sort date DESC  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

SOH Transaction Detail. Sort date DESC

Postby DannyC » Wed Aug 27, 2025 5:41 pm

Client wants the SOH transaction Detail to always sort with most recent on top.

What would I need in a plugin to have it sorted by DateIn descending?

Cheers
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: SOH Transaction Detail. Sort date DESC

Postby SBarnes » Thu Aug 28, 2025 7:32 am

If I am understanding you request correctly you don't need a plugin.

In the system settings under inventory there is a setting called StoredProcForInventoryTransactionHistoryGrid this points to a stored procedure that works like custom form tabs do, i.e. two datasets returned one for the schema and one for the data.

Just copy the procedure to one with a different name add your order by clause, and repoint the setting to your new procedure. :D
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: SOH Transaction Detail. Sort date DESC

Postby Mike.Sheen » Thu Aug 28, 2025 10:40 am

SBarnes wrote:If I am understanding you request correctly you don't need a plugin.

In the system settings under inventory there is a setting called StoredProcForInventoryTransactionHistoryGrid this points to a stored procedure that works like custom form tabs do, i.e. two datasets returned one for the schema and one for the data.

Just copy the procedure to one with a different name add your order by clause, and repoint the setting to your new procedure. :D


Wrong grid.

The tab captioned Transaction History on the Order tab of the Inventory Maintenance form uses the stored proc you mentioned, StoredProcForInventoryTransactionHistoryGrid.
InventoryMaint_Order_TransactionHistory.png


What Danny is asking about is the Transaction Detail of the SOH tab of the Inventory Maintenance form.
InventoryMaint_SOH_TransactionDetail.png


That grid does not used a stored proc. As a general rule, if there are user editable fields on a grid, then we cannot use a stored proc - and that is the case with the grid on the Transaction Detail tab of the SOH tab of the Inventory Maintenance form.

To see an example of how we sort grids programmatically, in Demo Data there is a plugin - Sort Notes - which changes the sort order of the notes grids for Debtors and Creditors and Contacts maintenance forms - just do the same as that - the grid on the Inventory Maintenance form is named grdSOH.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: SOH Transaction Detail. Sort date DESC

Postby DannyC » Thu Aug 28, 2025 11:03 am

in Demo Data there is a plugin - Sort Notes - which changes the sort order of the notes grids


Awesome. I'll review that plugin. Should be able to work it out.
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: SOH Transaction Detail. Sort date DESC

Postby DannyC » Thu Aug 28, 2025 2:29 pm

I have basically deciphered the Sort Notes plugin and tried to apply the relevant code to sort the inventory trans details by DateIn.

Something isn't right because the grid remains sorted by ascending DateIn.
Just as an aside, I have also added a line (now removed) to get SOHGrid.RowCount and it always returns 0.
Could it be that the grid isn't committed until after the ReadEnd event?

Here's my code
Code: Select all
#region "FormPlugin"
public class FormPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaFormPlugin
{

    public override object InitializeLifetimeService()
    {
        // returning null here will prevent the lease manager
        // from deleting the Object.
        return null;
    }

    public void SetupBeforeHandlers(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
    }

    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      if (JiwaForm is JiwaFinancials.Jiwa.JiwaInventoryUI.InventoryMaintenanceForm)
      {
         JiwaFinancials.Jiwa.JiwaInventoryUI.InventoryMaintenanceForm InventoryMainForm = (JiwaFinancials.Jiwa.JiwaInventoryUI.InventoryMaintenanceForm)JiwaForm;
         InventoryMainForm.Inventory.ReadEnd += Inventory_SortSOH;         
      }   
    }
   
   private void Inventory_SortSOH(object sender, System.EventArgs e)
   {
      JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory = (JiwaFinancials.Jiwa.JiwaInventory.Inventory)sender;
      JiwaFinancials.Jiwa.JiwaInventoryUI.InventoryMaintenanceForm InventoryMainForm = (JiwaFinancials.Jiwa.JiwaInventoryUI.InventoryMaintenanceForm)inventory.Client;
      //System.Diagnostics.Debugger.Launch();
      JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid SOHGrid = (JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid)(null);
      SOHGrid = InventoryMainForm.grdSOH;      
      SOHGrid.ActiveSheet.Columns["DateIn"].ShowSortIndicator = true;
      SOHGrid.ActiveSheet.SortRows(SOHGrid.ActiveSheet.Columns["DateIn"].Index, false, true);      

   }
}
#endregion
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: SOH Transaction Detail. Sort date DESC  Topic is solved

Postby Mike.Sheen » Thu Aug 28, 2025 3:08 pm

DannyC wrote:Something isn't right because the grid remains sorted by ascending DateIn.


Instead of sorting in a handler for the ReadEnd event, add a handler for the Inventory.SOHCollection.ReadEnd event instead and sort then.

That collection is lazy loaded, so it will only be read if the user clicks on the tab, or if the tab is already selected and a read or copy or new action takes place.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests