I put a "new " button inside a vf page and after I inserted that vf page inside a section on the Account page layout. When a user click new, has to be redirected on the custom Object Referente Interno's edit page. The problem is when a user click "new" the "onclick" JavaScript doesn't work. This is my vf page:

<apex:page standardController="account" extensions="referentixpartner">

<style type="text/css">
    padding: 0 10px;

   backgroud-color: grey;

function new(){
   if ( (typeof window.sforce != 'undefined') && (window.sforce!=null) ) {
    else {     
<apex:form >
<apex:pageBlock >
<h3>Referenti Interni </h3>
<apex:commandButton value="New Referente Interno" immediate="true" onclick="new()"/>
<apex:pageBlockTable value="{!lista}" var="l" styleClass="tabella" title="Referenti interni"  >
<apex:column headerValue="Action">
<apex:outputLink value="/{!l.Referente_int__r.Id}" style="color:blue; padding:2px; text-decoration: none" target="_blanck" >View</apex:outputLink>

<apex:column value="{!l.Referente_int__r.Name}" headerValue="Nome"/>
<apex:column value="{!l.Referente_int__r.Cognome__c}" headerValue="Cognome"/>
<apex:column value="{!l.Referente_int__r.Ruolo__c}" headerValue="Ruolo"/>
<apex:column value="{!l.Referente_int__r.Cellulare__c}" headerValue="Tel"/>
<apex:column value="{!l.Partner__c}" headerValue="PartnerShip"/>
<apex:column value="{!l.Azienda_gruppo_ADS__c}" headerValue="Azienda"/>

"/a04/e?retURL=%2Fa04%2Fo " is the URL where the user has to be redirected. Help me please

  • When you say "doesn't work", what do you mean? Do you get an error in the js console? What is your debugging showing you? Do you have any useful information that might help us? – Nick Cook Jul 21 '16 at 14:08
  • rigth sorry, when I click the button nothing happend, the page remain the same and in the log on developer console there is: /apex/VFpage name Success and the date time when I click the button obviously – L.benedettini Jul 21 '16 at 14:17

Change your javascript function name from new() to something else say new_method() as new is a keyword. It will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.