Moving an old UOM to a new UOMClass

Discussion created by rdavin Employee on Jan 25, 2012
Latest reply on Sep 21, 2015 by dsouzarich

We need to move an existing user-defined UOM to a new UOMClass. Over a year ago we added a UOM to a standard UOMClass. That UOM is used liberally in many attributes and attribute templates in many AFDatabases for a given PISystem. Recently, our engineering team has decided that that particular UOM really belongs in a new UOMClass; hence our need to move it.








For those who don't know, you can't delete a UOM if it is being referenced in any database by any attribute, attribute template, or table column. Technically you can try to remove the UOM from the UOMDatabase, but an exception will be thrown when you attempt to check-in. This integrity restriction is not limited to PISystem Explorer but built into the AFSDK itself.








Moving a UOM doesn't seem to be an easy or pretty task. Off the top of my head, I don't think you can strictly move it as much as duplicate it. Here's the steps that I think are required:





  1. Create the new UOMClass.
  2. Create the new UOM named similar to but different from the old UOM.
  3. Loop through every AFDatabase, for every attribute and attribute template that uses the old UOM and change it's UOM to be the new one. Note that in the name of completeness, one should also check the UOM in all lookup tables as well, but we've already verified that this particular UOM is not referenced in any tables (thank goodness!).
  4. Delete the old UOM.
  5. Rename the new UOM to be what the old UOM was.



The steps I listed above seem about as much fun as chewing on tin foil.  Is there a better way? Is there is easier way?