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
MiguelSeabraMiguelSeabra 

Select * Query

Hello,

I'm new to SF, and have been using it for the past 3days.... I've been programming a custom S-Control in Javascript in order to have access to the SF Database. I've had some problems but I've been able to figure them out. There's one problem that remains, though. I cannot seem to use a "Select *"-like expression in order to access all of the fields of an Account (for example)...

Can anyone help me with this problem?.. I've been reading that it has something to do with the API's describeSObject, but I'm still not certain of that.

Thank you for your help.

M.
tocktock
hello,
 I think you need to enter the fields in the 'select *' doesn't exist with the SOQL, the describeSObject simply describes the sobject and you can get a list of the fields to do this.
 Also 'developers sidekick' which is free will display the fields and even commar seperate the field list for you to cut and paste, so that query takes no time to make. 
 
hope that helps
MiguelSeabraMiguelSeabra
I know that I need to put the fields, but I want to make the expression as universal as possible, in order to make it usable for the other tables, such as "opportunities", "contacts" and so on...

The line of code I'm using is something like:

var queryResult = sforceClient.query("Select FirstName, LastName From Account", LayoutResult);

but this only retrieves the "FirstName" and "LastName" fields from the Account Table... what I need is a SOQL expression that accesses all the fields of the desired table... Someting like "Select "all fields" From Account"...

thank you

M.


DevAngelDevAngel
You need to think seriously about why you want all the fields for any object.  Once you have the query results, you typically need to know what fields you requested anyway to properly process the results.  Select * is intentionally not supported as it leads to lazy programming practices that can impact the performance of you scontrols.

Having said that, I would create a wrapper around the query call, something like
function queryA(objectName) {
    //Do a describeSObject on the object, caching the results
    //Create a select list from the list of fields
    //execute the query and return the results.
}
MiguelSeabraMiguelSeabra
I wanted all the fields because I needed to get that data to export it later to XML...

thank you for that wrapper suggestion. Probabilly it will solve the problem...

M.
Ron HessRon Hess
if you are developing new code, please switch to the supported toolkit for AJAX, you are using the unsupported Beta toolkit.
MiguelSeabraMiguelSeabra
Hi Ron,

In fact I am developing new code, but I don't know what toolkit you're talking about... some enlightenment would be much appreciated.

Thank you
M.

Ron HessRon Hess
so, check out this doc here

and the part about porting is here


use   

<script src="/soap/ajax/9.0/connection.js"></script>
<script src="/js/functions.js" type="text/javascript"></script>


rather than the Beta3.3 script, there are a few changes as you will see in the porting guide, the result is you are using the supported toolkit, which is easier to debug.
MiguelSeabraMiguelSeabra
ok, thank you ron...

I was using the following line of code to start it all up...

<script language="javascript" src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>

I've been reading and learning about the new Apex code and the possibilities the new Eclipse along with the new toolkit offer....

Thank you all for the contributions....

M.