Nevermind all of this. I got it working without using the Custom Code.
For future purposes check this thread out -