0

How can I retrieve result of the function assigned to variable in JavaScript?

So I have this code calling callback variable.

var result =  sforce.interaction.searchAndGetScreenPopUrl('07411111111', '', '', callback);

And the callback variable is a function:

        var callback = function (response) {
            if (response.result) {
                return response.result;
            } else {
                return response.error;
            }
        };

But when I then do:

console.log(result);

I get:

undefined

So my question is how can I return response of the callback function so it's accessible from result variable.

zachu
  • 671
  • 2
  • 7
  • 19

0 Answers0