Hide Request/Order button on portal without changing script on widget

Rohan04
Tera Contributor

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

 

2 ACCEPTED SOLUTIONS

@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

View solution in original post

Community Alums
Not applicable

top.document will work. Thanks for sharing this trick.

View solution in original post

10 REPLIES 10

Community Alums
Not applicable

document object is not available on service portal.

create a ui script to make it available

@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

Community Alums
Not applicable

top.document will work. Thanks for sharing this trick.

Thanks and Approciation you too!!! @Community Alums  after adding top.document its woking as per expectation.

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!!!