Page 1 of 1

Checking for serial uniqueness

PostPosted: Thu May 23, 2024 2:28 pm
by DannyC
If I want to write a plugin to check for the uniqueness of a serial number, it doesn't look I can just check
Code: Select all
inventory.SOHCollection.Added


Do I need to write a separate code block for GRN activation, shipment book-in activation, transfer activation, inventory transaction import, sales order credits, and every other event that writes to IN_SOH?

I could write a trigger on the database on INSERT, but I'd always thought SQL triggers are somewhat frowned upon.

For version 7.2.1

Re: Checking for serial uniqueness

PostPosted: Thu May 23, 2024 4:15 pm
by Mike.Sheen
DannyC wrote:Do I need to write a separate code block for GRN activation, shipment book-in activation, transfer activation, inventory transaction import, sales order credits, and every other event that writes to IN_SOH?


Yep.

DannyC wrote:I could write a trigger on the database on INSERT, but I'd always thought SQL triggers are somewhat frowned upon.


We dislike them because where sites are poorly documented, these types of things get forgotten about. Use them at your own peril... if it is documented well it shouldn't be a problem.

We recommend sites have their own Confluence (free for up to 10 users) to document their business specific workflows with Jiwa, and within that a page for "Upgrade Checklist and Prerequsites" which, if there are triggers, should have a step to disable triggers before upgrade, and another to enable them afterwards.

Re: Checking for serial uniqueness  Topic is solved

PostPosted: Fri May 24, 2024 3:33 pm
by DannyC
Righto.

In that case, I've knocked up a solution based on a trigger on IN_SOH.

In my testing it seems to work well. For example, activate a GRN with a serialised item and the serialno already exists, it pops up an error generated from the trigger and the GRN remains unactivated.
Have also tried with a stock transfer and it also popped up the same error.