How do I check if a Work Order has unallocated components

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

How do I check if a Work Order has unallocated components

Postby indikad » Thu Jul 23, 2026 9:26 pm

What is the best way to determine whether a Work Order still has unallocated component allocations?


I am trying to do this check on the save_start of Work Order window.

Is there already a WorkOrder property/method that indicates allocations are incomplete?
Should I be checking Stages, InputItems, OutputItems, LineDetails, or some other collection?
Which property indicates that an allocation is still outstanding/unallocated?

A small code example would be greatly appreciated.
Thanks.

the code below is the skeleton i have so far

Code: Select all
 public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {      
      if(JiwaForm is JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder )
        {
            JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder  workOrderForm = (JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder )JiwaForm;
            workOrderForm.WorkOrder.SaveStart += WorkOrder_SaveStart;
        }
    }
   private void WorkOrder_SaveStart(object sender, EventArgs e)
   {
      // works but count = 0
       JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.WorkOrder workOrder =(JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.WorkOrder)sender;

       foreach (JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.OutputItem outputItem in workOrder.OutputItems)
       {
           MessageBox.Show(
               "Output Item: " + outputItem.ItemNo + Environment.NewLine +
               "LineDetails Count: " +
               outputItem.LineDetails.Count.ToString());  // no errors but gives a count = 0 which is not right ??
            
           //break;
       }      
      
   }
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 185
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: How do I check if a Work Order has unallocated component

Postby Mike.Sheen » Fri Jul 24, 2026 2:33 pm

Code: Select all
outputItem.LineDetails.Count.ToString());  // no errors but gives a count = 0 which is not right ??


I'm not sure why you assert that the count of LineDetails for an output item should not be 0 - that just means at that point no output stock has been defined - it's normal if the output quantity is 0 for there to be no line details.

The work order has a property, Allocations - which is a collection of allocations between inputs and outputs - it has a property TotalQuantityOutputUnAllocated which I think is what you are after.

So you can do something like:,

Code: Select all
if (workOrder.Allocations.TotalQuantityOutputUnAllocated > 0)
{
    // there are unallocated amounts.
}
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: 2617
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 823

Re: How do I check if a Work Order has unallocated component

Postby indikad » Fri Jul 24, 2026 4:09 pm

Hi Mike,

Thanks for replying early.
<< I'm not sure why you assert that the count of LineDetails for an output item should not be 0>>
TBH I am not sure why too. I have been throwing all different kinds of logic and code at this and this is the last of the pile i had.


the code gave me an error on Jiwa 7.2.1 as below
on the code line
if (workOrder.Allocations.TotalQuantityOutputUnAllocated > 0)

Err:
JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.LineDetailsAllocationCollection.TotalQuantityOutputUnAllocated' is not supported by the language; try directly calling accessor method 'JiwaFinancials.Jiwa.JiwaBillOfMaterials.Work
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 185
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: How do I check if a Work Order has unallocated component

Postby Mike.Sheen » Fri Jul 24, 2026 4:16 pm

indikad wrote:the code gave me an error on Jiwa 7.2.1 as below
on the code line
if (workOrder.Allocations.TotalQuantityOutputUnAllocated > 0)

Err:
JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.LineDetailsAllocationCollection.TotalQuantityOutputUnAllocated' is not supported by the language; try directly calling accessor method 'JiwaFinancials.Jiwa.JiwaBillOfMaterials.Work


Oh, ok - I should have tested that - I didn't look closely enough - that property actually wants a parameter - a line detail of an output item.

So you would need to loop through output item, and for each one of those loop through the linedetail and pass that linedetail as a parameter to TotalQuantityOutputUnAllocated - it will return how much of that linedetail is unallocated.

There are other properties next to that one which might be more useful - like TotalQuantityInputAllocated - it all depends on what you're trying to do, and at what point your plugin is wanting to do it.
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: 2617
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 823

Re: How do I check if a Work Order has unallocated component

Postby indikad » Fri Jul 24, 2026 5:29 pm

Hi Mike,

My goal is to prevent closure of a Work Order when components remain unallocated - so I am looking for a property I should test ( if available ) .
Is there a property/method on Allocations that directly tells me:

input quantity required
input quantity allocated
input quantity unallocated

and can you provide a code sample on a Work Order SaveStart validation please ?
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 185
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: How do I check if a Work Order has unallocated component

Postby Mike.Sheen » Fri Jul 24, 2026 5:52 pm

Code: Select all
private void WorkOrder_SaveStart(object sender, System.EventArgs e)
{
   JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.WorkOrder workOrder = (JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.WorkOrder)sender;
   
   foreach(JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.OutputItem outputItem in workOrder.OutputItems)
   {
      foreach(JiwaFinancials.Jiwa.JiwaApplication.Inventory.SOH.LineDetail<JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.OutputItem> outputLineDetail in outputItem.LineDetails)
      {
         if (workOrder.Allocations.get_TotalQuantityOutputUnAllocated(outputLineDetail) > 0)
         {
            throw new Exception(String.Format("Output item {0} has a line detail not fully allocated.", outputItem.Inventory.PartNo));
         }
                     
         // workOrder.Allocations.get_TotalQuantityOutputAllocated(outputLineDetail) returns the total allocated (as opposed to unallocated)
         // And there are also other methods for input items:
         // workOrder.Allocations.get_TotalQuantityInputAllocated(inputItem)
         // workOrder.Allocations.get_TotalQuantityInputAllocated(inputLineDetail)
         // workOrder.Allocations.get_TotalQuantityInputAllocated(inputItem, outputLineDetail)
         // workOrder.Allocations.get_TotalQuantityInputAllocated(inputLineDetail, outputItem)
         // workOrder.Allocations.get_TotalQuantityInputAllocated(inputLineDetail, outputLineDetail)
      }
   }
}


Working plugin attached.
Attachments
Plugin Work Order Allocations.xml
(6.94 KiB) Downloaded 2 times
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: 2617
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 823


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 7 guests