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-03-2022 05:47 PM
Duplicate post: https://community.servicenow.com/community?id=community_question&sys_id=92ab5f8cdbe18110fd6325091396...
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2022 01:42 AM
hi
before adding this kind of comment please try to read thequestion and description carefully this post the question is "can i use GlideRecord in widget in client controller",the other post concerns"using BR through script include and client script to implemented in widget"
=> these are two different questions, so be careful next time before answering.
Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2022 06:27 AM
hi. you'd rather call the server in the client controller and pass the result back to it. then based on that, perform the action on the client you want.
Mark Correct and Helpful. Thanks!
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2022 07:18 AM
hi
thank you for your reply, how can i do that please , i don't have no idea can you give me example.