- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 03:45 AM
Hi,
I am have a category widget which initially shows only limited number of categories. I have a button in the widget "View All". When the user clicks that button, the widget should refresh and show all the categories. Below is my code am using. Where am i doing wrong. ctomasi nathanfirth pradeepksharma
Server:
if(input){
data.catParam = $sp.getParameter("kb_category");
data.kb = $sp.getValue("kb_knowledge_base");
var cats1 = new GlideRecord("kb_category");
cats1.addQuery("parent_id", data.kb);
cats1.orderBy('label');
cats1.query();
while(cats1.next()){
data.categories.push({label: cats1.getDisplayValue("label"), value: cats1.getUniqueValue()});
}
}
Client:
$scope.seeAll = function()
{
c.server.get().then(function(r) {
c.data.categories = r.data.categories;
});
};
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 07:47 AM
i think we traced down the error.
it looks like c.server.update returns data it self. so you can directly do
c.data.categories = r.newItems;
see if this works.
(please mark helpful/like/correct if it helps)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 07:26 AM
so what happens when you click view all ..any error is coming?
make sure you define data.newItems as an Array before pushing something in it.
after your if(input) line add below line
data.newItems = [];
also put console.log() in below function.
$scope.seeAll = function()
{
c.server.update().then(function(r) {
console.log(r.data.newItems);
c.data.categories = r.data.newItems;
});
};
see in browser console whether you are getting correct data or not. if data is not coming correct then put some logs on server side script. if data is coming right then issue must be on HTML side.
(please mark helpful/like/correct if it helps)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 07:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 07:47 AM
i think we traced down the error.
it looks like c.server.update returns data it self. so you can directly do
c.data.categories = r.newItems;
see if this works.
(please mark helpful/like/correct if it helps)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 07:51 AM
Fixed the issue. Thanks for the help provided.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 07:49 AM
Hi Rushit,
Now it is working great. I used c.server.refresh and it does the job well.
$scope.seeAll = function()
{
c.server.refresh().then(function(r) {
c.data.categories = r.data.newItems;
});
};