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
kearleykearley 

Apex Developer Guide - Code Not Working - HELP!

I am trying to work through the Apex Developer's Guide, but it's not going well. So far, I have attempted the first 3 pieces of code and all have not worked properly - or at all for that matter. I have the code typed in exactly as it appears on the page, but I get the little error triangle in the bottom left of my browser and the script does not run.
 
Am I missing something? I am using the lastest version of IE, Windows XP Prof. I'm quite familiar with html code so this isn't a foreign language to me, I know to remember to close tags and all of that stuff.
 
HELP! I really don't feel comfortable continuing through the book without figuring out my mistakes.
 
KE
cairlinncairlinn
is it the hello world example in the quick start?
can you copy/paste the code from your environment
also when you get the triangle in the browser - can you double click and send the full text of the error message

I will try to help

Peter

kearleykearley
Yes, the hello world is the last of the series that I had problems with.
 
There are two. One adds "World" to a field "Hello". That code:
 
public class MyHelloWorld {
    public static void addHelloWorld(Account [] accs) {
        for (Account a:accs) {
            if (a.Hello_c != 'World') {
                a.Hello_c = 'World';
            }
        }
    }
}
 
It says it needs this trigger:
 
trigger helloWorldAccountTrigger on Account (before insrt) {
    Account[] accs = Trigger.new
        MyHelloWorld.addHelloWorld(accs);
}
 
I can't get that one to work, nor can I get this to work. This script puts the text "Congratulations! Hello new Apex user! on a created custom S control called Hello World:
 
<html>
<head>
<type="text/javascript src="js/functions.js"></script>
<script src="/soap/ajax/11.0/connection.js"></script>
<script src="/soap/ajax/11.0/apex.js"></script>
<script>
function demo()  {
   var result = sforce.apex.execute('HelloWorld2' , 'sayHelloWorld',
{arg:"new Apex user!"});
y
   document.getElementById('userNameArea').innerHTML = 'Congratulations!'
         + '  ' + result;
}
</script>
</head>
<body onload=demo()>
   <div id=userNameArea>
   </div>
</body>
</html>
 
Thanks for offering to help! It is MUCH appreciated!!!!!!!!!!!
 
KE
Greg HGreg H
You're mixing two different examples. To test the MyHelloWorld class and helloWorldAccountTrigger trigger you simply need to make sure you have the field Hello_c on your account page layout and create a new account.  What you'll see is that the value "World" will be displayed even though you didn't enter a value.
 
The scontrol example is using a different class MyHelloWorld2.
-greg
kearleykearley
I stated that those were two examples. I can't get either of them to work. I checked and I have it as you say on the page, but I don't get "World" in the field when I create a new account.
 
The second one generates a blank page. I don't have them stored together in one piece of code. They are separate in SalesForce as they tell you to.