You need to sign in to do that
Don't have an account?

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 ="";
document.getElementById(a).style.display='none';
}
}
}
}
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';
}
}
}
}
there is indeed an article which says about recent changes in home page components. Let me know if it is related to your issue:
https://partners.salesforce.com/partnerAlert?id=a033000000CAObNAAX
Check the release note update here - http://docs.releasenotes.salesforce.com/en-us/summer14/release-notes/rn_forcecom_home_page_components.htm
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..