Adding a new BinLocation programmatically  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Adding a new BinLocation programmatically

Postby gkov3 » Wed Sep 05, 2018 10:22 am

Hi there,

What would be a recommended way to add a new BinLocation for a specific Logical Warehouse programmatically?

Thank you.
gkov3
Occasional Contributor
Occasional Contributor
 
Posts: 13
Joined: Tue Nov 11, 2014 4:10 pm
Location: Melbourne, VIC
Topics Solved: 1

Re: Adding a new BinLocation programmatically

Postby Scott.Pearce » Wed Sep 05, 2018 10:24 am

Which Jiwa version?
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Adding a new BinLocation programmatically

Postby gkov3 » Wed Sep 05, 2018 10:41 am

Version 7.2
gkov3
Occasional Contributor
Occasional Contributor
 
Posts: 13
Joined: Tue Nov 11, 2014 4:10 pm
Location: Melbourne, VIC
Topics Solved: 1

Re: Adding a new BinLocation programmatically  Topic is solved

Postby Scott.Pearce » Wed Sep 05, 2018 10:59 am

Use the warehouse maintenance business logic. Code:

Code: Select all
      string IN_Physical_RecID = "ZZZZZZZZZZ0000000000"; //Or you could iterate through Manager.PhysicalWarehouseCollection, looking at property "Description" to obtain the RecID you need.
      string IN_Logical_RecID = "ZZZZZZZZZZ0000000000"; //Or you could iterate through Manager.PhysicalWarehouseCollection[IN_Physical_RecID].LogicalWarehouseCollection, looking at property "Description" to obtain the RecID you need.
      
      var physicalWarehouse = Manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaWarehouses.PhysicalWarehouse>(null);
      physicalWarehouse.Read(IN_Physical_RecID);
      var logicalWarehouse = physicalWarehouse.LogicalWarehouses[IN_Logical_RecID];
      
      var newBinLocation = Manager.CollectionItemFactory.CreateCollectionItem<JiwaFinancials.Jiwa.JiwaWarehouses.BinLocation>();
      newBinLocation.Description = "My new bin location";
      
      logicalWarehouse.BinLocationCollection.Add(newBinLocation);
      
      physicalWarehouse.Save();


Remember that you will need to be referencing JiwaWarehouses.dll, and that you will also need a manager that is already set up and logged in (let me know if you need help obtaining a manager object).
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Adding a new BinLocation programmatically

Postby Scott.Pearce » Wed Sep 05, 2018 11:01 am

You could also look at Manager.CurrentLogicalWarehouse to obtain the RecID of the current warehouse if that's what you need.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Adding a new BinLocation programmatically

Postby gkov3 » Wed Sep 05, 2018 11:05 am

Thank you.

I was trying to create and configure a collection "BinLocationCollection" via CollectionFactory.CreateCollection<JiwaFinancials.Jiwa.JiwaWarehouses.BinLocationCollection> but hit a wall as it didn't have right interfaces.
gkov3
Occasional Contributor
Occasional Contributor
 
Posts: 13
Joined: Tue Nov 11, 2014 4:10 pm
Location: Melbourne, VIC
Topics Solved: 1

Re: Adding a new BinLocation programmatically

Postby Scott.Pearce » Wed Sep 05, 2018 11:10 am

Yeah, a bin location exists in a logical warehouse, and a logical warehouse exists in a physical warehouse - therefore it is necessary to read the parental objects to give context to the child objects.

When saving, a bin location would look to its owner logical warehouse for the IN_Logical_RecID value to save into the bin location table in the database.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Adding a new BinLocation programmatically

Postby gkov3 » Wed Sep 05, 2018 12:14 pm

Thanks again, it is working now,

Got an unexpected situation during a demo "as always happens" where inventory had an item with a specific bin description that wasn't listed in the [IN_BinLocationLookup] so the following method
JiwaStockTake.LineDetail.BinLocation.ReadRecordFromDescription was failing. Catching the exception, creating a bin on a fly and calling the failing method again fixed the issue.
gkov3
Occasional Contributor
Occasional Contributor
 
Posts: 13
Joined: Tue Nov 11, 2014 4:10 pm
Location: Melbourne, VIC
Topics Solved: 1

Re: Adding a new BinLocation programmatically

Postby Scott.Pearce » Wed Sep 05, 2018 12:26 pm

Bin locations were changed at some point relatively recently. They used to be a little loose and allowed users to type in ad-hoc bin location descriptions as stock was moved around. That has since has been tightened up so that now bin locations must be properly defined, and then selected by the user.

If you can give me some specifics regarding the problem you came across I can log a bug/fix our demo data so others don't get caught out by the same thing.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Adding a new BinLocation programmatically

Postby gkov3 » Wed Sep 05, 2018 12:33 pm

Sure, I will try to compile exact steps. I thought that was normal haven't tried to see how Jiwa handles it.
gkov3
Occasional Contributor
Occasional Contributor
 
Posts: 13
Joined: Tue Nov 11, 2014 4:10 pm
Location: Melbourne, VIC
Topics Solved: 1


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 13 guests

cron