Please see this code example:
***
<!--- Initialize Salesforce.com account --->
<cfset sfUserName = "xxx">
<cfset sfPassword = "xxx">
<!--- Initialize Salesforce API --->
<cfoutput>
<cfobject action="create" type="COM"
class="SForceOfficeToolkit3.SForceSession3.1" name="sfdc"/>
<cfset
x=sfdc.SetServerUrl("
https://www.salesforce.com/services/Soap/c/7.0")/>
<cfset x=sfdc.login("#sfUserName#","#sfPassword#")/>
</cfoutput>
<!--- Pass user last name --->
<cfset userLastName = "Barr">
<!--- Query Salesforce for last name --->
<cfset soql="select ID,FirstName, LastName,accountid,email
from Contact where lastname = '" & #userLastName# &
"'"/>
<cfset userResult = sfdc.query(soql,false) />
<!--- Display results --->
<cfloop collection="#userResult#" item="rec">
<cfoutput>
#rec.item("ID").value#<br />
#rec.item("FirstName").value#<br />
#rec.item("LastName").value#<br />
#rec.item("accountid").value#<br />
#rec.item("email").value#<br />
</cfoutput>
</cfloop>
***
When I loop through the COM collection, the value of
accountid is NULL. This is expected as this record has no
Account ID.
When I try to run this code I get the following exception:
***
Element VALUE is undefined in a Java object of type class
coldfusion.runtime.com.ComProxy referenced as
The error occurred in
C:\CFusionMX7\wwwroot\sftest\sfSearch.cfm: line 25
23 : #rec.item("FirstName").value#<br />
24 : #rec.item("LastName").value#<br />
25 : #rec.item("accountid").value#<br />
26 : #rec.item("email").value#<br />
27 : </cfoutput>
***
How can I handle NULL values so I dont get an exception?
Thanks so much for helping.
rb