This is an archived course — no longer updated. For current documentation see the official iDempiere docs. Today we help teams migrate from Sage ERP to iDempiere open source ERP — to join the sage.erpcommons.org community, email chuck@racktrust.com. Read the full story.

Clean Part Number (CleanMPN)

The purpose of this page is to discuss alternatives for maintaining a clean (free of any special characters - examples: "!@#$%^&*()" ) part number or MPN. If you ever need to mine data where the text is disturbed by special characters, this discussion will help.

Function to Clean a String

CREATE OR REPLACE FUNCTION chuboe_cleanmpn (text) RETURNS text AS $$
SELECT regexp_replace($1, '[^\w]+|_','','g') 
$$ LANGUAGE sql;
Discussion points:

Plugin

You can create a simple model event plugin. That sets a chuboe_mpn_clean field as part of a beforeSave event.