cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
790
Views
0
Helpful
1
Replies

Common JavaScript to Disable Add & Review for Individual Services

Looking to disable the Add & Review button for a particular service? Here's how.....

This item is contributed through one of our newScale Service Design consultants. I know that there is another post in the site (contributed by Brandy DeMarco at McKesson) with some of this information, however, the actual JavaScript code didn't seem to survive the migration from our previous site to this new site.

Step 1: Create the JavaScript "CMN_DisableAddReview" noted below:

CMN_DisableAddReview() {
  if (Moment === 'ordering') {
    locateFormElement = function(name) {
      var firstChild = document.getElementById(name).firstChild;
      while (firstChild.nodeType != 1)
        firstChild = firstChild.nextSibling;
      for (var x = 0; x<firstChild.childNodes.length; x++)
        if (firstChild.childNodes[x].nodeType == 1)
          return (firstChild.childNodes[x]);
    };
   
    // Locates the Add & Review header parent object within the HTML DOM
    FormHeaderName = 'cheader';
    locateFormElement(FormHeaderName).disabled = true;
   
    // Locates the Add & Review footer parent object within the HTML DOM
    FormFooterName = 'cfooter';
    locateFormElement(FormFooterName).disabled = true;
  }
}

Step 2:  Add the JavaScript in only 1 of the service specific AFCs in the Active Form Behavior Tab for the form onLoad Event

1 Reply 1

Chris Morris
Cisco Employee
Cisco Employee

We didn't want people to see it and wonder what they were missing out on, so we disabled it everywhere.

JS_Hide_AddReview_Button() {

    for(i=0; i //    alert(document.forms["serviceForm"].elements[i].value)
    if (document.forms["serviceForm"].elements[i].value == "Add & Review Order") {
//    alert("Found it!");
     document.forms["serviceForm"].elements[i].style.display = "none";
    }
  }
}

It is set to add the script on all forms.