Page 1 of 1

Book In activated - set the bin via plugin

PostPosted: Fri Aug 28, 2020 12:38 am
by DannyC
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?

Re: Book In activated - set the bin via plugin

PostPosted: Fri Aug 28, 2020 8:11 am
by DannyC
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.

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

PostPosted: Mon Sep 21, 2020 12:59 pm
by Mike.Sheen
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.