how to hide the button add to cart only in backend through client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-15-2022 07:30 AM
Hi,
i should hide the button add to cart only in the backend in the portal the button should be visible , i try it to check
Hide 'Add to Cart' to true not working and i try it No cart it works the button is hiding but it also hidding from the portal
i should hide the button through client script any suggestion please to resolve this issue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-15-2022 07:35 AM
Hi,
If you've tried the other methods hide the add to cart as mentioned below and elsewhere in the platform/documentation, then the next thing would be via DOM manipulation.
This would only be possible via DOM manipulation which isn't recommended or best practice however, it can still be done.
Please refer to this post which shows how to do it (it's based on a variable being a certain value, but the main point is, the major part of the script is what you want anyway).
You would need to ensure that the "Isolate script" checkbox on the client script form is set to false (if the field is not present on the form, add it, then set it to false).
Please mark reply as Helpful/Correct, if applicable. Thanks!
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-15-2022 08:47 AM
Hi
don't work for me i try it this solution i still see the button even isolate script is false,
i use client script not catalof client script
function onLoad() {
var catSysID = g_form.getUniqueValue();
alert(catSysID);
var ajax = new GlideAjax('test');
ajax.addParam('sysparm_name', 'getServiceCatalog');
ajax.addParam('sysparm_cat_sys_id', catSysID);
ajax.getXMLAnswer(function(answer) {
//if (answer.length > 0) {
if (answer == 'company') {
// alert('service catalog name:' + answer);
//document.getElementById('add_to_cart_button').style.display = 'none';
gel('oi_add_to_cart_button').style.display = 'none';
}
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-15-2022 08:53 AM
Hi,
I would recommend trying it without your GlideAjax, just to confirm it all works, then add in your GlideAjax. You're introducing an extra component that I wasn't covering above and you didn't specify that you were using in your original post.
So let's confirm what I've given actually works, in general, then, from there, you can add in your GlideAjax and then troubleshoot that with appropriate log statements, etc.
Please mark reply as Helpful/Correct, if applicable. Thanks!
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-15-2022 01:51 PM
even i don't use GlideAjax don' work i dont know why i try to create another client script onload the table sc_cat_item , isolate script is false , type is desktop
function onLoad() {
// var cart = document.getElementById('order_and_cart_v2');
cart.style.display='none'; don't work ;
// document.getElementById('add_to_cart_button').style.display = 'none'; don't work
$('oi_add_to_cart_button').hide(); don't work
}