How to get Announcements data without additional API call?
Is there an existing object that can be read for information about how many announcements are active, and for what timespan(s), which is loaded by every page? I assume that the announcement bar is bound to something like this, but I am not having luck finding it or accessing it.
I have a customization that I wish to trigger if there are any announcements that should be visible to the current user.
I am aware of a way to do this using the API, but I would like to avoid the extra call on every single page if there is a way to have this information that is already available on every page load.
Best Answer
-
Justin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
Could you use the .ajaxSuccess event and check the url of the call and if it's GetUserAnnouncements, store the responseJSON?
$(document).ajaxSuccess(function (event, xhr, settings) {
if (settings.url.indexOf('GetUserAnnouncements') > -1) {
var userAnnouncements = xhr.responseJSON;
//do something with the announcements?
console.log(userAnnouncements);
}
});
5
Answers
Could you use the .ajaxSuccess event and check the url of the call and if it's GetUserAnnouncements, store the responseJSON?
$(document).ajaxSuccess(function (event, xhr, settings) {
if (settings.url.indexOf('GetUserAnnouncements') > -1) {
var userAnnouncements = xhr.responseJSON;
//do something with the announcements?
console.log(userAnnouncements);
}
});
I like this approach. I am definitely having a "why didn't I think of that" moment right now.
I will try it out and report back. Thanks for the suggestion!
This got me started and everything is working as intended. Thanks again!