How to refresh a widget in service portal?

abhishekte
Mega Expert

Hello- I have a requirement to refresh a specific widget on a pages in service portal after specific time period. On My page, I have used 3 different widget and I don't want to refresh whole page to get the updated list (list data is coming from another instance using rest call) so I couldn't use $watch here.

Hence, I would like to update specific widget so that it make a server call and bring updated data from rest call and show in view.

Kindly let me know if anyone has implemented the same.

1 ACCEPTED SOLUTION

Thanks Nathan..You have pointed me in correct direction!!   The only catch here is that setTimeout won't work on client controller instead we have to use $timeout or $interval to call the function at regular intervals.



Many Thanks.


View solution in original post

4 REPLIES 4

michal29
Mega Guru

Hello Abhishekte,



If I understand correctly you wish to call the server and on return refresh widget on ServicePortal right ?


I would suggest the logic be like:



-> Add a dynamic block to SerivcePortal with your specified time interval (javascript setInterval)


-> In this interval, after the time, execute a Scheduled Import or Data Source to obtain data from rest Call


-> Wait for call to execute, monitoring sysimport_log


-> on answer receiving, query appropriate table that the import goes to


-> put the values on the widget


-> reload page, or put the data dynamically.



Regards,


Michal


He's referring to the new Service Portal in Helsinki which does not use content blocks


nathanfirth
Tera Guru

You could try doing something like this:



function($scope,spUtil) {


setTimeout(function(){


spUtil.update($scope);


}, 3000);


}


Thanks Nathan..You have pointed me in correct direction!!   The only catch here is that setTimeout won't work on client controller instead we have to use $timeout or $interval to call the function at regular intervals.



Many Thanks.