Page 2 of 2

Re: Syntax to get to inventory MinSOH, Safety Min, Safety ma

PostPosted: Wed Feb 24, 2021 5:53 pm
by SBarnes
At a quick guess call read on order levels first.

Which Mike has just confirmed.

Re: Syntax to get to inventory MinSOH, Safety Min, Safety ma

PostPosted: Thu Feb 25, 2021 2:20 pm
by DannyC
Nearly there (I hope) but orderLevel is still null. The only difference I can see is that you've supplied VB and I've done it in as C#.

Here's my code
Code: Select all
   private void Check_MinSOH(JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine item)
   {
      System.Diagnostics.Debugger.Launch();
        JiwaFinancials.Jiwa.JiwaApplication.Manager manager = item.Manager;
        JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory = manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaInventory.Inventory>(null);
      inventory.Read(item.InventoryID);

      foreach(JiwaFinancials.Jiwa.JiwaInventory.Month month in inventory.Months)
      {
         if (month.Index == System.DateTime.Now.Month)
         {
            foreach (JiwaFinancials.Jiwa.JiwaApplication.Inventory.Warehouse.PhysicalWarehouse phys in item.Manager.PhysicalWarehouseCollection)
            {
               foreach (JiwaFinancials.Jiwa.JiwaApplication.Inventory.Warehouse.LogicalWarehouse loglwarehouse in phys.LogicalWarehouseCollection)
               {
                  if (loglwarehouse.IN_LogicalID == item.SalesOrderLines.SalesOrder.LogicalWarehouseResidingIn.IN_LogicalID)
                  {
                     JiwaFinancials.Jiwa.JiwaInventory.OrderLevel orderLevel = inventory.OrderLevels.RetrieveOrderLevel(month, loglwarehouse);
                     MessageBox.Show(orderLevel.MinSOHUnits.ToString());
                  }
               }
            }
         }
      }
   }


null orderlevel.png

Re: Syntax to get to inventory MinSOH, Safety Min, Safety ma  Topic is solved

PostPosted: Thu Feb 25, 2021 2:36 pm
by SBarnes
Try this change, as Mike said the values need to be read into order levels

Code: Select all

 private void Check_MinSOH(JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine item)
   {
      System.Diagnostics.Debugger.Launch();
        JiwaFinancials.Jiwa.JiwaApplication.Manager manager = item.Manager;
        JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory = manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaInventory.Inventory>(null);
      inventory.Read(item.InventoryID);
     inventory.OrderLevels.Read(); ///*****************Line Added*********************************
      foreach(JiwaFinancials.Jiwa.JiwaInventory.Month month in inventory.Months)
      {
         if (month.Index == System.DateTime.Now.Month)
         {
            foreach (JiwaFinancials.Jiwa.JiwaApplication.Inventory.Warehouse.PhysicalWarehouse phys in item.Manager.PhysicalWarehouseCollection)
            {
               foreach (JiwaFinancials.Jiwa.JiwaApplication.Inventory.Warehouse.LogicalWarehouse loglwarehouse in phys.LogicalWarehouseCollection)
               {
                  if (loglwarehouse.IN_LogicalID == item.SalesOrderLines.SalesOrder.LogicalWarehouseResidingIn.IN_LogicalID)
                  {
                     JiwaFinancials.Jiwa.JiwaInventory.OrderLevel orderLevel = inventory.OrderLevels.RetrieveOrderLevel(month, loglwarehouse);
                     MessageBox.Show(orderLevel.MinSOHUnits.ToString());
                  }
               }
            }
         }
      }
   }


Re: Syntax to get to inventory MinSOH, Safety Min, Safety ma

PostPosted: Thu Feb 25, 2021 2:43 pm
by DannyC
YES! :D

Re: Syntax to get to inventory MinSOH, Safety Min, Safety ma

PostPosted: Thu Feb 25, 2021 3:24 pm
by Mike.Sheen
/me grumbles :/

Re: Syntax to get to inventory MinSOH, Safety Min, Safety ma

PostPosted: Fri Feb 26, 2021 4:53 pm
by DannyC
/me grumbles :/


In my defense I didn't know why or where I should use Inventory.OrderLevels.Read().
To my thinking, RetrieveOrderLevel(month, inventorywhouse) would be reading the values so it didn't occur to me I'd need to read twice using different code. Well, to me it's reading twice anyway :)

Re: Syntax to get to inventory MinSOH, Safety Min, Safety ma

PostPosted: Fri Feb 26, 2021 4:59 pm
by SBarnes
Don't feel too bad Mike when I look back at the post we both said call read on the order level guess he missed it from both of us /me grumbles too :/ :lol:

The reason the order level doesn't read by default unless you need the data for the tab there is no point in answering a question no one is asking and slow the screen down by loading unnecessary data.

This quite common on all the business objects.