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
new developer.ax420new developer.ax420 

New developer question

Hello All,


I am new to SalesForce so forgive me if this is an easy question.   This is driving me crazy.   I am trying to query the a custom client object in salesforce from an s-control and display the results on a custom tab.   I created the following code in an s-control and linked it to the tab page layout.   Can someone point out flaws in my thinking?   My current "stuck" point is that it never gets by the salesforce.connection.query statement (as the "after query" alert never shows up..the before query does show up).  Is this a syncronous vs asynchronous issue?  .   Any general thoughts about my code are appreciated.

PS...  I also realize I don't have any error code or anything in here right now.   Trying to keep it simple until it works

<html>
<head>
<script src="/soap/ajax/10.0/connection.js" type="text/javascript"></script>
</head>


<body>

<script type="text/javascript">

  alert("before query");
  var result = sforce.connection.query("select Client__c.Name from client");
  alert("after query");
    var it = new sforce.QueryResultIterator(result);

    while (it.hasNext()) {
        var Name = it.next();
        alert(Client__c.Name);
        document.write(Client__c.Name);
    }


</script>

</body>
</html>
aalbertaalbert
I don't think your query is valid.When querying a custom object, the __c must be appended to the custom object. For example: select Name from client__c

Also, I recommend a few tools that help when developing SOQL queries and scontrols:
1. Force.com IDE (which includes schema browser): http://wiki.apexdevnet.com/index.php/Force.com_IDE
    The schema browser helps you test and verify SOQL syntax

2. I develop SControls using Firefox so I can use some of the following developer plugins:
    Firebug: https://addons.mozilla.org/en-US/firefox/addon/1843
    Javascript Debugger: https://addons.mozilla.org/en-US/firefox/addon/216
    Web Developer Toolbar: https://addons.mozilla.org/en-US/firefox/addon/60


I hope this helps you continue to get started.



new developer.ax420new developer.ax420
Thanks for the reply.
 
 
Some thoughts:
 
 
1.   As per your thought, I changed the query to this and the code still doesn't appear to go beyond this point.
                  sforce.connection.query(“select Name from Client__c”);
 
2.   I installed Eclipse and the Force IDE but it won't allow me to connect.  I got the password/security token part right .. it then says "the metadata api needs to be enabled for my organization".   Any thoughts on how I do that?
 
 
3.    I started playing with the debuggers you listed and while I had some trouble, it appears in the debuggers that the code doesn't go beyond salesforce.connection.query either.
 
 
Do you or does anyone see anything else I am doing wrong in the code example?  Or does the code look right?   Any reason the code wouldn't continue after calling sforce.connection.query in the synchronous form?

Appreciated.
 
 
 


Message Edited by new developer on 12-30-2008 06:29 AM

Message Edited by new developer on 12-30-2008 07:07 AM

Message Edited by new developer on 12-30-2008 07:48 AM

Message Edited by new developer on 12-30-2008 07:48 AM
Greg HGreg H
The AJAX toolkit only works in orgs where the API is enabled. In Enterprise Edition and Unlimited Edition it is enabled by default. In Professional Edition it is only enabled after you pay an additional fee. My guess is that you are using Professional Edition and the API is not yet enabled.
-greg