xTuple.com xTupleU Blog & News Customer Support

Use of class code fields

We are working on a custom extension and have a need to store additional information that aligns with item class codes. I have searched Github for references to the classcode_type and classcode_modifier fields. Are either of these actively used by the system?

Even if they are not used, I would not use them for a custom script. Those fields might be used for some obscure reason, or they might start being used, or we might remove them.

What you should do for any custom data even if it is linked 1:1 with a core table is to create a new table in a custom schema and then save to that table, and read from that custom table when opening the screen.

So I would have a custom table customschema.custom_classcode (obviously call your schema and table whatever suits)
with columns:
custclasscode_classcode_id
custclasscode_attribute_1
custclasscode_attribute_2

Make sure you define a FOREIGN KEY constraint back to classcode_id with an ON DELETE CASCADE so that if a classcode is deleted it automatically clears up your custom table

Dave. We have followed this pattern for a lot of different needs. We were looking for a shortcut but this is sound advice. Thanks.

You’re welcome. Taking a little more time up front will save you a lot of effort in the future.

I would also recommend packaging all your customisations in to an Updater package so you can easily and safely move everything between a Development / Testing/ Production system.