function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
App DevelopmentApp Development 

Custom button script needed on visualforce page for salesforce 1

I have tried with adding script on custom button but its not visible in
salesforce 1 as we need to add the script in vf page and then access it.

below script (which i added in custom button) i need to add into Vf page,

(below page in link and javscript method i need to access from another vf page)

{!REQUIRESCRIPT("/apex/TestPage")}
runcode();

i tried with window.onload and other stuff but no luck.

Could ypu please suggest me the way to correct it?
NagendraNagendra (Salesforce Developers) 
Hi,

Custom button with source as on click JavaScript is not supported by Salesforce1.

You might want to use publisher action for achieving similar functionality, which is preferred way going forward. Or use a Visualforce page.

From documentation(https://help.salesforce.com/HTViewSolution?id=000187793):

Custom Buttons/Links ( ie: URL redirects) are now fully supported in Salesforce1 if their "Content Source" is Visualforce or URL from Spring'16 Release
The Visualforce page must also have the "Available for Salesforce Mobile Apps" checkbox checked.

If you use URL custom buttons or links to pass parameters to standard pages in Salesforce Classic—such as pre-populating fields when creating a record—or passing Report parameters from a custom link, this behavior doesn’t work in Salesforce1 or Lightning Experience.

Regards,
Nagendra