URGENT!! Service Portal: Wait condition in the client controller for the response from Server Script (Similar to Ajax call)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2018 10:11 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2018 10:18 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2018 12:06 AM
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