- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 06:47 PM
Hi,
I am trying to use the header to display the number of active record in the Service Portal.
Since some records are located on external platforms, i want it to be asynchronous.
To do so, i am not initially loading the data, waiting for the page to load, and then calling the server to run the queries in the background.
The problem is that the server call doesn't seem to work. I could make it work in other widgets but not in the header.
With the following code:
c.getData = function () {
c.data.action = 'get_data';
c.server.update().then(function (response){
console.log(response);
});
};
//Server
gs.log("Input: " input);
if (input) {
gs.log("Server!");
}
When c.getData is executed in the client, i still have "Input: undefined" in the logs and never get into the IF condition on the server side.
This only happens with the Header widget...
Thanks for helping.
MP
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 08:42 PM
I could fix the problem by putting the "if (input)" early in the server script and only retrieving menu items in the else condition.
Which makes me believe that something in the following code (OOTB in the header), prevent data from being updated correctly:
data.loginWidget = $sp.getWidgetFromInstance('login-modal');
// Defines the support queue ID that will be linked to by the Live Chat link in header
data.connect_support_queue_id = $sp.getValue('sp_chat_queue');
data.login_page = $sp.getValue('login_page');
data.profileBtnMsg = gs.getMessage("User options");
var menu = $sp.getValue("sp_rectangle_menu");
data.menu = $sp.getWidgetFromInstance(menu);
if (data.menu && data.menu.data) {
data.menu.data.replace = true;
// Hide login if menu already has link to login
data.hasLogin = false;
if (data.menu.data.menu.items) {
for(var i in data.menu.data.menu.items) {
var item = data.menu.data.menu.items[i];
if (item.type == 'page' && item.sp_page == data.login_page)
data.hasLogin = true;
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 08:42 PM
I could fix the problem by putting the "if (input)" early in the server script and only retrieving menu items in the else condition.
Which makes me believe that something in the following code (OOTB in the header), prevent data from being updated correctly:
data.loginWidget = $sp.getWidgetFromInstance('login-modal');
// Defines the support queue ID that will be linked to by the Live Chat link in header
data.connect_support_queue_id = $sp.getValue('sp_chat_queue');
data.login_page = $sp.getValue('login_page');
data.profileBtnMsg = gs.getMessage("User options");
var menu = $sp.getValue("sp_rectangle_menu");
data.menu = $sp.getWidgetFromInstance(menu);
if (data.menu && data.menu.data) {
data.menu.data.replace = true;
// Hide login if menu already has link to login
data.hasLogin = false;
if (data.menu.data.menu.items) {
for(var i in data.menu.data.menu.items) {
var item = data.menu.data.menu.items[i];
if (item.type == 'page' && item.sp_page == data.login_page)
data.hasLogin = true;
}
}
}
}