• Sarju Mulmi
  • NEWBIE
  • 25 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
All,

I'm trying to call an apex function from a javascript button. I've read the developer guide and several relevant posts on this forum, but still can find out the issue. I have not created any namespace prefix for my dev org. The conroller is different from the Helper class with the web service method.
VF page:
<apex:page showHeader="false" >
  
 <script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script>
 <script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script>
 
 <script type="text/javascript">
    
    function testRemote(){
        var id = sforce.apex.execute("HelperClass","getContactId",{});
        alert('id is: '+id);
        }
 
 </script>
  
 <div>  
    <button onclick="testRemote();">
      Remote
    </button>
  </div>
 </apex:page>

Apex class for webservice:
global class HelperClass {
    
    webService static String getContactId(){
       
        String id = '003j0000002CQ3B';
        return id;
    	}
}
Much appreciated,

Sarju
 
All,

I'm trying to call an apex function from a javascript button. I've read the developer guide and several relevant posts on this forum, but still can find out the issue. I have not created any namespace prefix for my dev org. The conroller is different from the Helper class with the web service method.
VF page:
<apex:page showHeader="false" >
  
 <script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script>
 <script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script>
 
 <script type="text/javascript">
    
    function testRemote(){
        var id = sforce.apex.execute("HelperClass","getContactId",{});
        alert('id is: '+id);
        }
 
 </script>
  
 <div>  
    <button onclick="testRemote();">
      Remote
    </button>
  </div>
 </apex:page>

Apex class for webservice:
global class HelperClass {
    
    webService static String getContactId(){
       
        String id = '003j0000002CQ3B';
        return id;
    	}
}
Much appreciated,

Sarju
 
can you please provide me step wise on how to complete this task .i am bit confused .....