0

I have a requirement to create a custom button that will open a pop up window with some options to select. Currently i've built a VF page and called it from the custom button. But i need to expose this button in different detail page and if we call VF page from custom button, i need to use standard controller of one particular object..and cannot be reused for other related object. So i want the popup window to be opened when we execute onclick javascript from custom button, like : window.open=('/apex/newRic?id={{item.id}}','blank'); . But then i'm not able to add window open property to that button to specify the size of the popup

class:

public class test_k {
  Public string s{
    get;
    set;
  }

  public test_k(ApexPages.StandardController controller) {
  }
  public List<SelectOption> getMatrix() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('None','----None----'));

    list<Account_List_vod__c> pv= [select name,id from Account_List_vod__c];
    for (Account_List_vod__c p:pv) {
      options.add(new SelectOption(p.id,p.name));
    }
    return options;
  }

public void addlineItem() {
  newAccount_List_Item_vod__c(Account_vod__c='001Z000000yH6qg',Account_List_vod__c=s);
}
}

Page:

<apex:page standardController="Account" showHeader="false" extensions="test_k" sidebar="false">
  <apex:form>
    <apex:selectList value="{!s}"  multiselect="false" size="1">
      <apex:selectOptions value="{!Matrix}"/>
    </apex:selectlist>
    <apex:commandButton value="OK" action="{!addlineItem}"/>
  </apex:form>
</apex:page>

enter image description here

1 Answer 1

1

If you want to use Javascript you will need to convert the button. Set the behaviour to "Execute JavaScript" and Content Source to "OnClick JavaScript"

enter image description here

2
  • If i use onclick javascript in custom button i'm not able to set window open property, which is doable in case of custom button in VF page
    – user59759
    Commented Oct 14, 2015 at 8:45
  • 1
    You can use the following:window.open(URL, '_blank', 'height=600,width=600,resizable=yes,scrollbars=yes,toolbar=no,menubar=no'); I have copied the same properties that you have used above, also see here this w3schools.com/jsref/met_win_open.asp for details on window.open()
    – Tim
    Commented Oct 14, 2015 at 9:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .