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