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
duduavduduav 

can i call salesforce api from html page using AJAX Toolkit

can i call salesforce api from html page using AJAX Toolkit ?

i know that you can call salesforce api  from visual force page , is it possible  from html ?

 

 

Imran MohammedImran Mohammed

Yes you can call, include the below code in your head tag of html

<script src="/soap/ajax/20.0/connection.js"></script>

<script src="/soap/ajax/20.0/apex.js"></script>
<script type="text/javascript" src="/js/functions.js"></script>
duduavduduav

thanks for quick reply ,

do you have a full example for using those scripts ;

thanks, duduav  

Imran MohammedImran Mohammed

Make the changes to the below code.

function sampleTest()

{

 

var result = sforce.connection.query(Add you query here enclosed in quotes);
var resultedRecords = result.getArray('records');
if(resultedRecords.length > 0)
{
 for(i=0;i<resultedRecords.length;i++)
 {
 <<variableOrWhateveryouwant>> = resultedRecords[0].FieldNamesOfObject;
 }
}
}
You can also invoke Apex class functions declared as Webservice. Let me know if you need further help.

 

duduavduduav

thanks again, in my question i forget to mention that the html page is not on the sales force  server 

i am guessing that change everything 

Imran MohammedImran Mohammed

I am not sure whether this can be done or not.

But if you are using programming language like Java or .Net, then you can invoke Salesforce api.

duduavduduav

thanks again