I have this same code sample (from tech support) already.
When you say "handles" foreign keys what do you mean?
What I want is the object and its entire dependent tree including all data in all child objects cloned. This code only clones the target object and skips all relations downward and makes an exact copy of foreign key values which will not always work (ie. if I clone a patternCollection child of a Project class I don't want it to be the child of Project 1 (cloned) but the child of the newly created (cloned) Project object).
Pete