From: ldtech on
I'm doing my first SalesForce connection web site and have a question on how to
retrieve and possibly cast some objects from my query. The basic code (after
login which works fine) is to query the Contact table. After that, I want to
grab some simple data back from it like "firstname" and such but I run into
errors that "firstname" doesn't exist. I was told a possible solution to this
might be to cast the return results into "Contact" objects. I'm not really
sure how to do that since I don't have a java class attached that has any
salesforce code in it, I'm simply trying to work through their webservice layer
and retrieve this data to output on our website (ok, and eventually to update
some of it).

Is there a way to do this without integrating any java modules? All the
information I've found so far is from 2004 (4 years old!) so I hope someone is
still knowledgeable about this :) I posted some of the code below that works
as well (left out a lot of the login code that already works).

<cfset queryName = sfObject.query("SELECT firstname FROM contact")>
<cfset queryRecords = queryName.getRecords()>
<cfset varCounter = 0>
<cfloop index="varCounter" from="1" to="#ArrayLen(queryRecords)#">
<cfdump var="#queryRecords[varCounter]#">
</cfloop>
<cfdump var="#sfObject.describeGlobal().getTypes()#">
</cfoutput>

From: GArlington on
On Apr 17, 8:26 pm, "ldtech" <webforumsu...(a)macromedia.com> wrote:
> I'm doing my first SalesForce connection web site and have a question on how to
> retrieve and possibly cast some objects from my query. The basic code (after
> login which works fine) is to query the Contact table. After that, I want to
> grab some simple data back from it like "firstname" and such but I run into
> errors that "firstname" doesn't exist. I was told a possible solution to this
> might be to cast the return results into "Contact" objects. I'm not really
> sure how to do that since I don't have a java class attached that has any
> salesforce code in it, I'm simply trying to work through their webservice layer
> and retrieve this data to output on our website (ok, and eventually to update
> some of it).
>
> Is there a way to do this without integrating any java modules? All the
> information I've found so far is from 2004 (4 years old!) so I hope someone is
> still knowledgeable about this :) I posted some of the code below that works
> as well (left out a lot of the login code that already works).
>
> <cfset queryName = sfObject.query("SELECT firstname FROM contact")>
> <cfset queryRecords = queryName.getRecords()>
> <cfset varCounter = 0>
> <cfloop index="varCounter" from="1" to="#ArrayLen(queryRecords)#">
> <cfdump var="#queryRecords[varCounter]#">
> </cfloop>
> <cfdump var="#sfObject.describeGlobal().getTypes()#">
> </cfoutput>

Unfortunately, I do not know what your "sfObject" is, but if it is
anything what it looks like it should be, then you should be able to:
<cfdump var="#queryRecords#" /> after your <cfset queryRecords =
queryName.getRecords() />
If it is a CF like array of data then just use it, if it is an array
of objects with methods (as it looks like it may be) you might have to
do something like
queryRecords[varCounter].getFirstname() to fetch firstname from any
record...
From: ldtech on
I should add that for those who don't know, the sfObject is the base object
which the other objects extend. So a Contact is an extension of an sfObject.
I figured the query would return the correct object type but it does not, a
dump reveals it's being returned as the base sfObject. So I guess at the very
least I need to know if you can convert a complex object to another complex
object that extends it in CF. I found one or two other people saying they
somehow completed their projects in CF (not that many) but I'm thinking more
and more they did it through some extension of java and not much CF at all.

From: GArlington on
On Apr 18, 5:11 pm, "ldtech" <webforumsu...(a)macromedia.com> wrote:
> I should add that for those who don't know, the sfObject is the base object
> which the other objects extend. So a Contact is an extension of an sfObject.
> I figured the query would return the correct object type but it does not, a
> dump reveals it's being returned as the base sfObject. So I guess at the very
> least I need to know if you can convert a complex object to another complex
> object that extends it in CF. I found one or two other people saying they
> somehow completed their projects in CF (not that many) but I'm thinking more
> and more they did it through some extension of java and not much CF at all.

If you want a query to return something other than sfObject you should
NOT use sfObject.query(), because it calls query method of sfObject
directly.
Try to call objExtendingSfObject.query(), this should return (if
programmed correctly) the objExtendingSfObject...