If you want Javascript to execute on load of a Standard Salesforce UI page, you can accomplish this via a Hompage Component.
Step 1. Create a Homepage Sidebar Component.
Setp 2. Inside Homepage Component, add the Javascipt via "Edit HTML Source" on the Component. Have the Javascript execute on window load.
Step 3. Add the Homepage Component to layout.
This is process I've used several times to execute javascript on load of a standard detail page. You can do things like remove elements from the page based on element names or ids from standard page layouts that you can't normally do without replacing with a VF page.
My only word of advice is be careful. Its a very "Hackish" workaround, and changes by Salesforce at any release could break the DOM model if you use Javascript.
I used the below code to run Java Script on clicking a button.
Hope this helps.
/* This code allows the javascript to access the API and push data into the Org.*/ {!requireScript("/soap/ajax/10.0/connection.js")}; sforce.connection.session = "{!$Api.Session_ID}"; function updateContact( ) { try { var c = new sforce.SObject("Contact"); c.Id = "{!Contact.Id}"; c.LastName = c.LastName; c.Title = "Delete"; var result = sforce.connection.update([c]); if (result[0].getBoolean("success") == false ) { alert(result[0].errors.message); return; } window.top.location.href=window.top.location.href; } catch (e) { alert(e); } }
If you want Javascript to execute on load of a Standard Salesforce UI page, you can accomplish this via a Hompage Component.
Step 1. Create a Homepage Sidebar Component.
Setp 2. Inside Homepage Component, add the Javascipt via "Edit HTML Source" on the Component. Have the Javascript execute on window load.
Step 3. Add the Homepage Component to layout.
This is process I've used several times to execute javascript on load of a standard detail page. You can do things like remove elements from the page based on element names or ids from standard page layouts that you can't normally do without replacing with a VF page.
My only word of advice is be careful. Its a very "Hackish" workaround, and changes by Salesforce at any release could break the DOM model if you use Javascript.
Thanks. This was useful for me in one way. However, if I need to execute a javascript on Article page, where do I add? I could not see the sidebars getting loaded in the Article tab.
If you want Javascript to execute on load of a Standard Salesforce UI page, you can accomplish this via a Hompage Component.
Step 1. Create a Homepage Sidebar Component.
Setp 2. Inside Homepage Component, add the Javascipt via "Edit HTML Source" on the Component. Have the Javascript execute on window load.
Step 3. Add the Homepage Component to layout.
This is process I've used several times to execute javascript on load of a standard detail page. You can do things like remove elements from the page based on element names or ids from standard page layouts that you can't normally do without replacing with a VF page.
My only word of advice is be careful. Its a very "Hackish" workaround, and changes by Salesforce at any release could break the DOM model if you use Javascript.
Other than that, it's fine.
All Answers
I used the below code to run Java Script on clicking a button.
Hope this helps.
/* This code allows the javascript to access the API and push data into the Org.*/
{!requireScript("/soap/ajax/10.0/connection.js")};
sforce.connection.session = "{!$Api.Session_ID}";
function updateContact( )
{
try
{
var c = new sforce.SObject("Contact");
c.Id = "{!Contact.Id}";
c.LastName = c.LastName;
c.Title = "Delete";
var result = sforce.connection.update([c]);
if (result[0].getBoolean("success") == false )
{
alert(result[0].errors.message);
return;
}
window.top.location.href=window.top.location.href;
}
catch (e)
{
alert(e);
}
}
updateContact();
Thanks,
VK
If you want Javascript to execute on load of a Standard Salesforce UI page, you can accomplish this via a Hompage Component.
Step 1. Create a Homepage Sidebar Component.
Setp 2. Inside Homepage Component, add the Javascipt via "Edit HTML Source" on the Component. Have the Javascript execute on window load.
Step 3. Add the Homepage Component to layout.
This is process I've used several times to execute javascript on load of a standard detail page. You can do things like remove elements from the page based on element names or ids from standard page layouts that you can't normally do without replacing with a VF page.
My only word of advice is be careful. Its a very "Hackish" workaround, and changes by Salesforce at any release could break the DOM model if you use Javascript.
Other than that, it's fine.
Thanks. This was useful for me in one way. However, if I need to execute a javascript on Article page, where do I add?
I could not see the sidebars getting loaded in the Article tab.
Hi,
I would like to execute javascript code on article page.
Please help me if there are any workaround.