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
Uttpal chandraUttpal chandra 

How to get id when user click on Detail Page Button

Hi All,
Currently When a user is clicking on Detail Page Button I am loading a javscript to create a Pop up. But I am not able to fetch Id of a record.

Anyone help me on this.

(function() {
    var width = 500;
    var height = 300;
    var title = "Run Template";

    var box = new SimpleDialog("salesforce" + Math.random(), true);
    box.displayX = true;
    box.isMovable = false;
    // set your html content here
      '<iframe src="/apex/RunTemplate" style="border:none;" width="100%" height="'+ (height - 30)+'px" />'
    //set the height of the modal
    box.dialog.children[1].style.height = height + 'px';;

    //if displayX is set to true, then override standard close event by this code
    box.dialog.getElementsByClassName('dialogClose')[0].onclick = function() {
      // you can add code to reload the page or redirect to another page 
    //optional : add this to close the modal onclick of the overlay background
    box.background.addEventListener('click', function() {
    // if you want to be able to close the modal from the Visualforce page
    window.addEventListener('message', function(event){
      if ( === 'close'){

Thanks in advance
Deepali KulshresthaDeepali Kulshrestha
Hi Uttpal,
The code for this button looks like this:

var leadIds = {!GETRECORDIDS($ObjectType.Lead)};
if (!leadIds || leadIds.length < 1) {
alert('Please select at least one Contact to upload.');
} else {
var baseUrl;

var hostnameParts = location.hostname.split('.');
if (hostnameParts[0] == 'ctct2') {
baseUrl = '<a href="https://ctct2.%27" target="_blank" rel="nofollow">https://ctct2.'</a> + hostnameParts[1] + '';
} else {
baseUrl = '<a href="https://ctct2.%27" target="_blank" rel="nofollow">https://ctct2.'</a> + hostnameParts[0] + '';

var form = document.createElement('form');
form.action = baseUrl + '/apex/UploadWizardStep1';
form.method = 'post';

var hiddenTypeField = document.createElement('input'); = 'type'; = 'type';
hiddenTypeField.type = 'hidden';
hiddenTypeField.value = 'Lead';

var hiddenUploadIdsField = document.createElement('input'); = 'uploadIds'; = 'uploadIds';
hiddenUploadIdsField.type = 'hidden';
hiddenUploadIdsField.value = leadIds;



Please replace Line one with below given line of code, 
I am working for lead you can replace with any object.

var leadIds = '{!Lead.Id}';

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha