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
AshiAshi 

Invoke Apex class from HTML

Hi,

 

Can I invoke an apex class from my HTML page in an external application. If yes, then please tell me how can we do that.

 

Thanks

 

 

kamlesh_chauhankamlesh_chauhan

Create VF page with apex class and call the function in VF page action.

Include it to public site of the Force.com site.

Include force.com site URL to your HTML.

 

- Kamlesh Chauhan

LogicRain Technologies

kamlesh@logicrain.com

www.logicrain.com

OyeCodeOyeCode

Sounds plausible

AshiAshi

Thanks, I have few of doubts:

 

Create VF page with apex class and call the function in VF page action.

Which function are you referring here to call

 

Include it to public site of the Force.com site

How

 

Include force.com site URL to your HTML.

How do you recommend to include the URL in HTML(which section/tag)

 

Thanks

 

kamlesh_chauhankamlesh_chauhan

(1) Create VF page with apex class and call the function in VF page action.

The method of apex class you need to invoke from HTML, please call it in VF page.

Example:

<apex:page controller="MyController" action="{!MyAction}>

</apex:page>

 

(2) Go to Setup --> Develop --> Site option. Create site and add above VF page to the site. You can use this URL.

 

(3) Use site URL with VF page in your HTML anywhere you need. Like on button click, URL etc.. It is up to you..

 

Regards,

Kamlesh Chauhan

LogicRain Technologies

kamlesh@logicrain.com

www.logicrain.com

AshiAshi

Thank Kamlesh, but my requirement is slightly different, described below:

 

  1. I do not want to navigate to VF page
  2. I want to have my own interface developed in HTML and
  3. I want to use SOQL query results written in an apex class in my HTML page
  4. And I prefer to invoke Apex class in my HTML page through REST services.

Thanks

 

 

 

 

 

 

kamlesh_chauhankamlesh_chauhan

Ok, understood.

 

The best solution is to create webservice in Salesforce and utilize it in HTML.

 

Try to search in salesforce docs for more help.

AshiAshi

Sounds good.

 

Would you like to point to some link or tutorial for the same.

 

Thanks