Thursday, January 6, 2011

Hide ISV Button.

I needed to hide a button that I added to my form using the ISV.config file. IN ISV file you can specify the button to be display in create / update mode. You can have only one tag per entity.

Here is the requirement:
I have to display 5 ISV button in the form. Out of which 4 to be displayed in both Create and Update mode. But there is one button which has to be displayed only in Update Mode. If you use below XML line in ISV.config file

It will display all button in both mode. But there is no provision where i can specify some of the button in create and update mode.
So I've to hide the button using Client side scripting on Load of the form.

Below is the fucntion which hides the button:
// HIDE ISV Button
function HideISVButton(strButtonToolTip){
   var tag = document.getElementsByTagName("LI");
   for(x = 0; x < tag.length; x++)
   {
      if(tag[x].getAttribute("title") == strButtonToolTip)
      {
         button = document.getElementById(tag[x].getAttribute("id"));
         if(button != null)
            button.style.display = "none";
         x = tag.length;
      }
   }
}

// Call the function to hide the button:
HideISVButton("Click this button to Line Activate");

The above code loops through all objects on the webpage with a tag name of "LI" looking for one that has a title of ‘Click this button to Line Activate’ which is specified in the ISV.Config file. Once the code finds the correct ToolTip of a button, it gets hidden.

No comments: