Skip to main content
Ponram K 님이 #Apex에 질문했습니다
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 ="";

document.getElementById(a).style.display='none';

}

}

}

}

 
답변 3개
  1. 2015년 10월 27일 오전 11:44
    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()

    {

    if(document.getElementsByName("sendEmail")[0]!=null)

    document.getElementsByName("sendEmail")[0].style.display = 'none';

    if(document.getElementsByName("sendEmail")[1]!=null)

    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..
0/9000