For instance:
featureLayer.on("selection-complete", function (result){
var pPoly = result.features[0].geometry;
});
console.log(pPoly);
the console returns undefined
You are having scope and order of execution issues.
To do what you want, you need to do something like this.
var pPoly;
function saySomething() {
console.log(pPoly);
}
featureLayer.on("selection-complete", function (result) {
pPoly = result.features[0].geometry;
saySomething();
});dojo/on does not return a Promise, so you cannot use then with it.
I'd recommend you look over this blog post
Take your JavaScript Up a Notch
And in particular look at closures.