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
RajeevKumarRajeevKumar 

Getting error 'sforce.sObject' does not contain a definition for 'Any'

How to fix this error.
getting this error on line
string fName = con.Any[0].InnerText;

Please help.

My code:


private void querySamplenew()
{
QueryResult qr = null;
sfdc.QueryOptionsValue = new sforce.QueryOptions();
sfdc.QueryOptionsValue.batchSize = 250;
sfdc.QueryOptionsValue.batchSizeSpecified = true;

qr = sfdc.query("select FirstName, LastName from Contact");

bool bContinue = true;
int loopCounter = 0;
while (bContinue)
{
Console.WriteLine("\nResults Set " + Convert.ToString(loopCounter++) + " - ");
//process the query results
for (int i=0;i {
sforce.sObject con = qr.records[i];
string fName = con.Any[0].InnerText;
string lName = con.Any[1].InnerText;
if (fName == null)
Console.WriteLine("Contact " + (i + 1) + ": " + lName);
else
Console.WriteLine("Contact " + (i + 1) + ": " + fName + " " + lName);
}
//handle the loop + 1 problem by checking to see if the most recent queryResult
if (qr.done)
bContinue = false;
else
qr = sfdc.queryMore(qr.queryLocator);
}
Console.WriteLine("\nQuery succesfully executed.");
Console.Write("\nHit return to continue...");
Console.ReadLine();
}
RajeevKumarRajeevKumar
I fixed this issue.
Arun BalaArun Bala
Hi Rajeev,
I have also stumbled at a similar scenario. Could you please let me know how you fixed this one ? Thanks.
RajeevKumarRajeevKumar
Use partner api..
aucyrisaucyris

When I switch from the Enterprise to the Partner WSDL, I still get the same error along with the following:

 

Original Error:

sforce.DescribeGlobalResult does not contain a definition for 'sobjects'

 

Additional Error when using Partner API:

The type or namespace name 'Contact' could not be found

 

The documentation states the following:

 

Unfortunately, in the definition of the SObject class, Visual Studio does not wrap these to class references in the System.Xml.Serialization.XmlIncludeAttribute that are part of the SObject definition. To work around this problem in Visual Studio, you need to edit the XmlIncludeAttribute settings for Case and Event as shown below. This does not apply to C# and only applies when using the enterprise version of the WSDL.


  System.Xml.Serialization.XmlIncludeAttribute(GetType([Event])), _
  System.Xml.Serialization.XmlIncludeAttribute(GetType([Case])), _

 

How do I edit those settings?

SuperfellSuperfell

The partner API will not contain a definition of Contact, that largely being the point of the partner API. (that there are no static schema mappings).

 

sobjects on DescribeGlobal are part of the v17 api, it doesn't exist on earlier versions, perhaps you're mixing sandbox and production WSDLs (most sandbox's are now on v17, while all production instances are still at v16).