Custom Field Functions will be a good start, failing that you'll need to use a UDF and dump the result into a UDM.
well, I've written following
Please Login to Report Topic
Please Login to Share Feed