Thanks @VeenaVikraman , we were used to running groovy on our on prem instance but since it wasn't completely supposed in cloud hadn't gone down that route. I think we'll go down the servlet route next, thanks!
Veena - Thank you for the information, this is very helpful. We're running into a similar issue although how could we create a script for cloud? Thanks