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
sudarshasudarsha 

pass variable from custom button(onclickjavascript) to visual force page?

Hai friends,

i created a custom button by onclickjavascript,now i want to pass variable from custom button to visual force with out url append.
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
var url = parent.location.href;
var records = {!GETRECORDIDS($ObjectType.Account)};

if (records[0] == null) {
    alert("Please select at least one record ");
}

else{
window.open("/apex/SelectedView"+"?selectedrecords="+records);
}


i did like this but ,is there any other way to pass records variable from custom button to visual force page(not url append) .
Ramu_SFDCRamu_SFDC
I assume you are talking about passing the selected records from one VF page to another VF page. To do this you need to make sure that both these VF pages are using common controller. The below post explains more about this

https://developer.salesforce.com/forums/?id=906F0000000AaoMIAS


sudarshasudarsha
not for two pages,i want from custom button to visual force page

here this is page "/apex/SelectedView"
Cloud_forceCloud_force
yo can use pagerefernce object for passing parameters in a visualforce page.

But you will have to go through a apex class method. I.e call that method from JS and then from method you can go to VF page.

Thanks,
http://www.forcexplore.com/2014/07/wrapper-class-in-salesforce.html
sudarshasudarsha
i tried like that but here
we can pass ids from onclickjavascript custom button to static method in apex class,by using this here pagereference is not working.