can i use GlideRecord in widget in client controller
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2022 04:33 PM
Hi,
i have a requirement to limit the number of item saved as bundle, once user add an item in the cart he can click at abutton named saved as bunlde i want to make a control in this button once user have 5 item saved an alert shoul ddispaly and he cannot saved the item, this item is stored in a table named "u_article_favoris". my ideai is to put this code in the onclcik of the button save as bundle: should this work or i should change something, any suggestion please
c.saveBundle = function() {
/////////// my code
var id = gs.getUserName();
var count = 0;
var gr = new GlideRecord('u_article_favoris');
gr.addActiveQuery();
gr.addQuery('sys_created_by', id);
gr.query();
count = gr.getRowCount();
if (count > 5) {
alert('you cannot save you have 5item ');
gr.setAbortAction(true);
} else {
gr.setAbortAction(false);
}
///////////////////////////////////
var saveCartModalCtrl;
var unregister = $scope.$on('$sp.service_catalog.cart.save_cart', function() {
saveCartModalCtrl.close();
});
var saveCartModal = angular.copy(c.data.saveCartModal);
saveCartModal.options.afterOpen = function(ctrl) {
saveCartModalCtrl = ctrl;
};
saveCartModal.options.afterClose = function() {
unregister();
c.saveCartModal = null;
saveCartModalCtrl = null;
};
c.saveCartModal = saveCartModal;
$rootScope.$broadcast("$sp.service_catalog.cart.update");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2022 07:27 AM
hi
thank you for your reply, how can i do that please , i don't have no idea can you give me example.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2022 11:28 AM
Hi. If your issue is resolved and my response has helped, plese consider marking Correct and Helpful. Thanks!
Martin Ivanov
2022 Community Rising Star
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024