Page 1 of 1

Stock Transfer. Reading the warehouse, setting the reason

PostPosted: Mon Jul 27, 2015 6:18 pm
by DannyC
Been fiddling with this one for a while now & have reached the point of posting a topic.
When a Stock Transfer is created, I want to read the warehouse it is created in and change the stock transfer reason.

The general point of the plugin is to set the reason (and the subsequent write off/on accounts) based on the warehouse the transfer is in.

Using the BusinessLogicPlugin class I cannot find any property of the Stock Transfer which provides the logical warehouse name or LogicalID. Not only that, but the StockTransferReason property is read only anyway. I figure I must be barking up the wrong tree completely.

Can you assist?

Cheers

Re: Stock Transfer. Reading the warehouse, setting the reaso  Topic is solved

PostPosted: Tue Jul 28, 2015 8:52 am
by Scott.Pearce
DannyC wrote:Using the BusinessLogicPlugin class I cannot find any property of the Stock Transfer which provides the logical warehouse name or LogicalID.


Code: Select all
MyStockTransferObject.LogicalWarehouseResidingIn.IN_LogicalID


or

Code: Select all
MyStockTransferObject.LogicalWarehouseResidingIn.Description


DannyC wrote:Not only that, but the StockTransferReason property is read only anyway.

It's an entity. To change it, you would "read" the stock transfer reason you want, thus:

Code: Select all
MyStockTransferObject.StockTransferReason.ReadRecord(RecIDtoRead)


or:

Code: Select all
MyStockTransferObject.StockTransferReason.ReadRecordByName("Damaged")


or:

Code: Select all
MyStockTransferObject.StockTransferReason.ReadDefault


You will find that this use of entities, which must be "read" instead of "set", is becoming increasingly common.

Re: Stock Transfer. Reading the warehouse, setting the reaso

PostPosted: Tue Jul 28, 2015 9:03 am
by DannyC
That's awesome Scott.
Plugin tested & working nicely.
My flaw was not typing a dot after the LogicalWarehouseResidingIn to see if there was anything else after it. And same for StockTransferReason.

Cheers