1_ There's already a TargetUID expression available for the behavior.
A way of doing would be : example
Side question:
New features from the beta gets added to the manual in the next stable version.
According to the Ashley's release cycle, it should be available in r120 in a few weeks.
Though, templates and examples are already added/shipped with the current beta release.
I hope that helps.
Edit: Over ninja'd. Well, examples are always good I guess.