Stock Transfer line added. Get SOH  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Stock Transfer line added. Get SOH

Postby DannyC » Mon Sep 30, 2024 12:27 pm

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?
Attachments
Plugin Attkey Add SOH to Stock Transfer line.xml
(36.01 KiB) Downloaded 23 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 658
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

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

Postby Mike.Sheen » Mon Sep 30, 2024 12:35 pm

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.
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: 2488
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 770

Re: Stock Transfer line added. Get SOH

Postby DannyC » Mon Sep 30, 2024 1:34 pm

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.
User avatar
DannyC
Senpai
Senpai
 
Posts: 658
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests