I want to call method in an apex class in header part of customer portal which is a HTML page (not a VF page).

Is it possible to access apex class method in such a way, If yes, then how to start on this?

  • Only HTML or Javascript is a possible way ?
    – SF_user
    Commented Sep 3, 2014 at 8:31
  • But how? can you provide some reference
    – Pankaj
    Commented Sep 3, 2014 at 9:10

3 Answers 3


https://developer.salesforce.com/page/Apex_Web_Services_and_Callouts Check this out. This is a very useful blog.


I believe you have an external page and you are trying to access an apex method. For this the apex class must be a web service class. This means a global class exposed. like this

 global class AccountPlan {

   webservice static Plan createAccountPlan(Plan vPlan) {

           //add logic here......

And from your HTML page you can call this method using AJAX calls.

Hope this was useful


Try something like this :

VF :

<div id="header">
    <script language="javascript">
        var myControllerMethod = '{!myControllerMethod}';

Controller :

 public with sharing class MyClass {
        public String getMyControllerMethod () {
            //Do some stuff

            return null;
  • Sorry But its not working. How will you identify the class for the method "getMyControllerMethod"
    – Pankaj
    Commented Sep 3, 2014 at 9:34
  • If it's a VisualfForce page, you may have the controller field in your <apex:page> tag. Here it's <apex:page controller="MyClass">
    – SF_user
    Commented Sep 3, 2014 at 9:41
  • 1
    In my understanding the question is not about Visualforce, but places where you can upload/configure pure HTML. In a VF page you can reference by controllername.methodname, but can that be done in non-VF pages on the platform? Commented Sep 3, 2014 at 10:04
  • No i am not having VF page i am doing it on HTML page. However i found the solution salesforce.com/us/developer/docs/apexcode/Content/…
    – Pankaj
    Commented Sep 3, 2014 at 10:58

You must log in to answer this question.

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