Book In activated - set the bin via plugin  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Book In activated - set the bin via plugin

Postby DannyC » Fri Aug 28, 2020 12:38 am

I've got a client who wants to set the same bin for all items when a book in gets activated. Sort of like a receiving bay where all received stock comes in. Until the warehouse staff pack it away in its proper bin.
But it's not the Default Bin, just a receiving bin.

Theres no Activated event, so I am using/tried the SaveStart and SaveEnd event and checking whether the bookin is being activated like this:
Code: Select all
if (bookIn.Activated && !bookIn.OriginalActivated)


That's fine - it gets into the if codeblock on SaveStart.

The problem is, there's no LineDetails property or any other property I can find to set the bin, so instead I am just firing a SQL command
Code: Select all
string Sql = @"UPDATE IN_SOH ";
Sql += "SET BinLocationDesc = 'MyReceivingBin' ";
Sql += "FROM SH_BookInLines INNER JOIN ";
Sql += "SH_BookInDetailLines ON SH_BookInLines.BookInLineID = SH_BookInDetailLines.Parent_RecID ";
Sql += "INNER JOIN IN_SOH ON SH_BookInDetailLines.IN_SOH_LinkID = IN_SOH.LinkID AND SH_BookInLines.BookInLineID = IN_SOH.SourceID ";
Sql += "INNER JOIN SH_BookInMain ON SH_BookInLines.BookInID = SH_BookInMain.BookInID ";
Sql += "WHERE SH_BookInMain.BookInID = @BookinID";


But when I check the SOH, the bin isn't getting written. The Default Bin is getting populated instead. I can run the exact same SQL in a sql query window and it will update, but I want it to update upon activation.
I am assuming that its not working on SaveStart because the IN_SOH lines wouldn't exist yet.

But on SaveEnd, the
Code: Select all
if (bookIn.Activated && !bookIn.OriginalActivated)
isn't working, I'd guess because both properties are now true?

How would I be able to populate the IN_SOH.BinLocationDesc with a value?
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29

Re: Book In activated - set the bin via plugin

Postby DannyC » Fri Aug 28, 2020 8:11 am

Never mind - although it would be interesting to see what the feedback might be I have sussed a workable solution.

Basically I am setting a boolean
Code: Select all
if (bookIn.Activated && !bookIn.OriginalActivated)
{
   //We're activating
   isActivating = true;
}
else
{
   isActivating = false;
}


Then on the BookIn.ReadEnd event, I just check if that boolean is true & perform my sql UPDATE statement.
It seems to work, so I'll run with it.
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29

Re: Book In activated - set the bin via plugin  Topic is solved

Postby Mike.Sheen » Mon Sep 21, 2020 12:59 pm

DannyC wrote:The problem is, there's no LineDetails property or any other property I can find to set the bin, so instead I am just firing a SQL command


Yes there is.

The bookin line has a property, LineDetailCollection, which has a BinLocation property.

You should just listen to the Added event of that collection and then in there set the BinLocation.
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: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron