Page 1 of 1

Stock Transfer line added. Get SOH

PostPosted: Mon Sep 30, 2024 12:27 pm
by DannyC
See plugin attached.

I want to get the SOH at the time when a new transfer line is added. I have created a custom field to save the value.
I'm using the event Line.Added.

The plugin appears to get the SOH when each transfer is read from the database. So if I am looking at old transfers and using the back/forward buttons the plugin is getting the SOH as at now.
I don't want it to do this. I need the figure to remain fixed as at when exactly the line was added as a new line, and only then.
So effectively old transfers (prior to this plugin) should all show a 0 for SOH.

What event should I use to ensure my code is only fired when a new line is added?

Re: Stock Transfer line added. Get SOH  Topic is solved

PostPosted: Mon Sep 30, 2024 12:35 pm
by Mike.Sheen
DannyC wrote:What event should I use to ensure my code is only fired when a new line is added?


You can still use the same event as you are - Lines.Adding - but in your handler, you need to inspect the Lines.StockTransfer.IsReading flag and not do anything if it is set to true. It will be set to true when reading a record from the database and false when a line is being added that is not part of the read.

Re: Stock Transfer line added. Get SOH

PostPosted: Mon Sep 30, 2024 1:34 pm
by DannyC
you need to inspect the Lines.StockTransfer.IsReading


Cheers. That was the trick. I was looking for a flag on the line, or the lines. But not the main business logic.