+ Start a Discussion
Ponram KPonram K 

Home page component which include Java script is not working after salesforce upgradation

Hi all,

Our project demands to hide fields in some layout by using Home Page component.so I initially used Javascript in Home Page Component for achieve our requirement.But after upgradation of salesforce, components that contain JavaScript, CSS, iframes are restricted and stop working properly.I am attaching my code which i done before salesforce up-gradation.

Could anyone give solution for this? It would be great.

Code which work fine before SF upgradation:-

//Below If condition to hide the Service details in maintenance sheet  Edit Layout for system type: Disabled/Nursecall Alarm
if (document.location.href.toString().indexOf("/a0F") != -1 && document.location.href.toString().indexOf("/a0F/o") == -1 && document.location.href.toString().indexOf

("/e?") != -1 ) { 
//checking the system name
var e  = document.getElementById("00ND0000005Ec8j");
var strUser = e.options[e.selectedIndex].value;
//alert('Systm name '+strUser);

if(strUser != "Disabled/Nursecall")

for(var i=1;i<document.getElementsByTagName('Label').length;i++)
if(document.getElementsByTagName('Label')[i].innerHTML== "SLA Power Calibration Qty")
var a =document.getElementsByTagName('LABEL')[i].htmlFor;
document.getElementsByTagName('LABEL')[i].innerHTML ="";

Chandra Sekhar CH N VChandra Sekhar CH N V
Does upgrade mena here changing to lightning experience?

there is indeed an article which says about recent changes in home page components. Let me know if it is related to your issue:

In Summer ’15 we will start removing unsupported code from HTML Area home page components. As a result, components that contain JavaScript, CSS, iframes, or other unsupported markup might stop working properly. To use JavaScript or other advanced HTML elements in your home page component, we recommend that you use a Visualforce Area component instead.

Check the release note update here - http://docs.releasenotes.salesforce.com/en-us/summer14/release-notes/rn_forcecom_home_page_components.htm
Hi Ponram..
Save your java script stored in a Static resource.
Create a Home page component of type custom link..
Add the component to the home page layout...

Please find below the sample script to hide a standard button. 

function hideBtns()

document.getElementsByName("sendEmail")[0].style.display = 'none';
document.getElementsByName("sendEmail")[1].style.display = 'none';
if (window.addEventListener) {
window.addEventListener("load", hideBtns, false);
else if (window.attachEvent) {
window.attachEvent("onload", hideBtns);
console.log('Standard email buttons are hidden!');

This would work... Please check it and let me know on any concerns..