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
diegartediegarte 

Problem with sforce.apex.execute

Hi,
 
I'm just starting with Apex, and I'm having problems with my first example:
 
I have the following code:
 
global class WSPage
{
    WebService static String getDefault(String Text)
    {
        return 'My Company ' + Text;
    }
}
 
Then, I try to use this code in a SControl:
 
<html>
<head>
<script type="text/javascript" src="/js/functions.js"></script>
<script type="text/javascript" src="/soap/ajax/10.0/connection.js"></script>
<script type="text/javascript" src="/soap/ajax/10.0/apex.js"></script>
<script>
function demo()
{
    var strResult = sforce.apex.execute('WSPage', 'getDefault', {Text:'Testing...'});
    document.getElementById('Header').innerHTML = strResult;
}
</script>
</head>
<body onload=demo()>
<div id='Header'>
</div>
</body>
</html>
 
I'm getting a JavaScript error on my tab.  Does anybody know what the problem could be?
 
Thanks
Ron HessRon Hess
this code is correct, i pasted it into my test org and it runs correctly, returning a tab that contains

My Company Testing...

i am using firefox, also tested this on IE7

what browser are you running?
also,
what is the javascript error that you see?

Ron HessRon Hess
wild guess,
you may want to modify this line to include quotes, like so:

<body onload="demo();" >
diegartediegarte
I was testing this with an old developer account.  I just created a new developer account and pasted the code and it works properly.
 
Any ideas on the difference between old salesforce accounts and new ones?
 
Thanks
 
Diego Arteaga
Ron HessRon Hess
old may not have Apex code turned on