I think this thread is a bit similar to what you are looking for:
Please check it out, there are sample code from the Community in the thread that addresses what the user was looking for, which looks similar to what you are looking for.
If this does not work, please let us know, and we will try to come up with something new.