- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2024 11:54 PM
I have a requirement of to hide Request/Order button on portal for the particular catalog item based on the condition of the variable. For that the requirement is that without touching the widget of the form, need to do the things...I have tried writing catalog client script but i am unable to reach upto the solution....
Your help will we Appriciated!!!
Thanks,
Rohan K
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2024 12:07 AM
@Rohan04 - Please use top.document instead of document in the script and let me know the result.
function onChange(control, oldValue, newValue, isLoading) {
console.log('onchange triggered');
console.log('isLoading:', isLoading);
console.log('newValue:', newValue);
if (isLoading || newValue == '') {
return;
}
var condition = (newValue == 'single');
console.log('condition:', condition);
if (condition){
hideAddToCartButton();
}else{
showAddToCartButton();
}
//Type appropriate comment here, and begin script below
}
function hideAddToCartButton(){
console.log('hiding add to cart button');
var addToCartButton = top.document.getElementById("submit-btn");
console.log('hiding add to cart button12');
if (addToCartButton){
addToCartButton.style.visibility = "hidden"; // Hide the Order / Submit button ONLY from Service Portals
}else{
console.error('add to cart button not found');
}
}
function showAddToCartButton(){
var addToCartButton = top.document.getElementById("submit-btn");
if (addToCartButton){
addToCartButton.style.visibility = "visible"; // Show the Order / Submit button ONLY from Service Portals
}else{
console.error('add to cart button not found');
}
}
Thanks & Regards,
Vasanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2024 12:20 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2024 11:58 PM
document object is not available on service portal.
create a ui script to make it available
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2024 12:07 AM
@Rohan04 - Please use top.document instead of document in the script and let me know the result.
function onChange(control, oldValue, newValue, isLoading) {
console.log('onchange triggered');
console.log('isLoading:', isLoading);
console.log('newValue:', newValue);
if (isLoading || newValue == '') {
return;
}
var condition = (newValue == 'single');
console.log('condition:', condition);
if (condition){
hideAddToCartButton();
}else{
showAddToCartButton();
}
//Type appropriate comment here, and begin script below
}
function hideAddToCartButton(){
console.log('hiding add to cart button');
var addToCartButton = top.document.getElementById("submit-btn");
console.log('hiding add to cart button12');
if (addToCartButton){
addToCartButton.style.visibility = "hidden"; // Hide the Order / Submit button ONLY from Service Portals
}else{
console.error('add to cart button not found');
}
}
function showAddToCartButton(){
var addToCartButton = top.document.getElementById("submit-btn");
if (addToCartButton){
addToCartButton.style.visibility = "visible"; // Show the Order / Submit button ONLY from Service Portals
}else{
console.error('add to cart button not found');
}
}
Thanks & Regards,
Vasanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2024 12:20 AM
top.document will work. Thanks for sharing this trick.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2024 01:08 AM
Thanks and Approciation you too!!! @Community Alums after adding top.document its woking as per expectation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2024 01:06 AM
Yes, after adding top.document inside code its working now....
Thanks and Appriciatation to you @Vasantharajan N for your valuable time and the solution too!!!