https://community.bistudio.com/wiki/surfaceIsWater
I'm pretty sure that one works. Maybe your problem lies elsewhere?
Aside from that, you can look at this command:
https://community.bistudio.com/wiki/selectBestPlaces
quite useful for random placement of things. It allows you to avoid water in the first place and also gives you some extra options.