The CreatorCon Call for Content is officially open! Get started here.

URGENT!! Service Portal: Wait condition in the client controller for the response from Server Script (Similar to Ajax call)?

ashwanikumar
Tera Expert

Hi All,

 

Is it possible to put await condition in the client script to wait for the response from the server in the Service portal widget?

My client controller script must wait for the server response and then execute. 

 

Thanks,

Kumar

2 REPLIES 2

venkatiyer1
Giga Guru

Hi Kumar,

 

You can use promise as it comes by default in angular $http. See the post below for more details:

https://community.servicenow.com/community?id=community_question&sys_id=f9bc0fe5db9cdbc01dcaf3231f961985

 

Abhijeet Upadhy
Tera Expert

Hello Ashwini

Use this call back timeout code to wait for the response till the "response_back" variable gets a value.

 

Script:

$http(options).then(function(response){

var response_back = response;

});

$scope.call_back_function();

 

$scope.call_back_function= function()
{
if(response_back == "")
{
$window.setTimeout($scope.call_back_function, 100);
}
else

{

//use response_back here

}

 

Thanks

Abhijeet Upadhyay