How to manage a unique constraint when creating variants?

We have a field called UID that is unique for each Item in addition to the Item Code. When creating variants of these Items, ERP duplicates this UID and hence it goes against this constraint.

How do we manage this scenario and generate meaningful variant UIDs during variant creation?

Managed to solve this by hooking in the Form Events and checking for the variant_of key in frm.doc and then setting the appropriate value using frm.set_value.

Albeit, this only work for creating a single variant. When creating variant using Create Multiple Variants, the ERP creates Background Jobs that bypasses the form logic and constraints. So, it still fails.