+ Start a Discussion
anil savaliya 11anil savaliya 11 

Sidebar home component doesn't work after summer 15 with Javascript

Hey,

As we know  salesforce removing Javascript support from side bar  home component after summer 15,Also salesforce added visualforce in home componenet,Since Visualforce page in iframe.Visuaforce in home component is not able to interact with salesforce standard UI.

Any Idea or any research or javascript , we should control standard salesforce UI through home component.


Thanks,
Anil
Best Answer chosen by anil savaliya 11
Gaurav NirwalGaurav Nirwal
Try this, it works in Summer'14:

1. create a StaticResouce "YourStaticResourceName" upload a JS file containing whatever you need (e.g. jquery) and add a command in the end, like 2. console.log('bingo!');
2. go to Setup > Home > Custom Links
3. create a new link call it "injection"
4. Behaviour = "Execute JavaScript"
5. Content Source = "Onclick JavaScript" (don't get irritated, you won't have to click!)
at the body enter {!REQUIRESCRIPT("/resource/1402932484000/YourStaticResourceName")}
6. go to Setup > Home > Home Page Components
7. create a new one
8. call it "injection-box"
9. pick type "Links" (instead of HTML-Area we used before)
10. click next
11. pick "injection" we created above
12. save it
13. got to Setup > Home > Home Page Layouts
14. add "injection-box" to your layout
go to anywhere it worked before and check for 'bingo!' in your console. See that 'YourStaticResourceName' is successfully injected to the standard pages :-)
And finally it seems to be even officially supported, look at this:
http://help.salesforce.com/HTViewHelpDoc?id=customize_functions_i_z.htm#REQUIRESCRIPT

All Answers

Gaurav NirwalGaurav Nirwal
Try this, it works in Summer'14:

1. create a StaticResouce "YourStaticResourceName" upload a JS file containing whatever you need (e.g. jquery) and add a command in the end, like 2. console.log('bingo!');
2. go to Setup > Home > Custom Links
3. create a new link call it "injection"
4. Behaviour = "Execute JavaScript"
5. Content Source = "Onclick JavaScript" (don't get irritated, you won't have to click!)
at the body enter {!REQUIRESCRIPT("/resource/1402932484000/YourStaticResourceName")}
6. go to Setup > Home > Home Page Components
7. create a new one
8. call it "injection-box"
9. pick type "Links" (instead of HTML-Area we used before)
10. click next
11. pick "injection" we created above
12. save it
13. got to Setup > Home > Home Page Layouts
14. add "injection-box" to your layout
go to anywhere it worked before and check for 'bingo!' in your console. See that 'YourStaticResourceName' is successfully injected to the standard pages :-)
And finally it seems to be even officially supported, look at this:
http://help.salesforce.com/HTViewHelpDoc?id=customize_functions_i_z.htm#REQUIRESCRIPT
This was selected as the best answer
anil savaliya 11anil savaliya 11
Hey Mathewas,

Thanks for Explanation.It's work awsome. :)



 
Adam HaithcoxAdam Haithcox
Just used this before they wipe out my embedded js in the upcoming summer '15 release. I added an onlick function that created a used redirection on the link instead of just being a dead link sitting there. I named mine "Reset My Security Token" and set the onlick to change the window.location to the relative reset security token path. Works great.

Thanks @Gaurav!
Prasad KairamkondaPrasad Kairamkonda
@Gaurav You simply picked up the content from @Uwe Heim reply at http://salesforce.stackexchange.com/questions/38918/end-of-javascript-sidebar-workarounds

You should quote the source when you simply pick up the solution.
Eyal AzulayEyal Azulay
I've used this feature to customize our standard View and Edit pages extensively, investing many dev hours. But this week it stopped working. Firebug shows that the Javascript file is not even being loaded. We use a jQuery script to:
- Extend field width in edit pages. The default width of text fields is very narrow.
- Remove words from labels which are repeating words already in the section header title, greatly simplifying page layouts.
- Renaming specific page header titles that share the same Object (with different Record Types) to remove confusion for the users.

I found this article, which claims that running javascript from the sidebar is no longer supported: http://salesforce.stackexchange.com/questions/38918/end-of-javascript-sidebar-workarounds

Although it mentions VisualForce Area component as a possible alternative, it clearly states that VisualForce Area components run in an iframe which prevents any javascript in it from interacting with the main page. This article also confirms this: https://help.salesforce.com/HTViewHelpDoc?id=home_page_components_custom_vf_overview.htm&language=en_US

What are my options? It would really be awful to lose all our customizations, which we have come to rely on.