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
Sorn1Sorn1 

Update Account Sample not working

I have just started using SalesForce and am having trouble getting the update Account Sample to work.
 
 

//create the account object to hold our changes

sforce.sObject updateAccount = new sforce.sObject();

//need to have the id so that API knows which account to update

//set a new value for the name property

updateAccount.Id = "0016000000hkyAAN";

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

System.Xml.XmlElement nameElement = doc.Xml.XmlElement("Name");

 

nameElement.InnerText = "New Account Name from Update Sample";

updateAccount.Any = new System.Xml.XmlElement[] { nameElement };

updateAccount.type = "Account";

sforceP.SforceService binding = Utility.GetPartnerBinding (this.Context);

//call the update passing an array of object

sforce.SaveResult[] saveResults = binding.update(new sforceP.sObject[] { updateAccount });

 

System.Xml.XmlDocument doc  does not have a member doc.Xml.XmlElement

Can somebody advise

many thanks

SuperfellSuperfell
it should be System.Xml.XmlElement nameElement = doc.CreateElement("Name");

Can you tell me where you got the sample code? i'll get it updated.

Message Edited by SimonF on 06-27-2008 07:36 AM
Sorn1Sorn1
Many thanks for you help Simon
 
I got the sample code from  the PDF ------ Force.com Web Services API Developer's Guide. You can find it on page 75 The method is  updateAccountSample()

The same sample can also be found at:

http://www.salesforce.com/us/developer/docs/sforce70/wwhelp/wwhimpl/common/html/wwhelp.htm?context=sforceAPI_WWHelp&file=sforce_API_partner_examples.html

Once again thankyou for your help

Roy

SaaniaSaania
I am getting errors at the following lines (in the same document).

Code:
updateAccount.Any = new System.Xml.XmlElement[] { nameElement };
updateAccount.type = "Account";

 Error messages are:

XXXX.Enterprise.sObject' does not contain a definition for 'Any'.
XXXX.Enterprise.sObject' does not contain a definition for 'type'.


Thanks,



SuperfellSuperfell
This is partner WSDL sample code, you're using the enterprise WSDL.
SaaniaSaania
Where can I find the enterprise WSDL sample code?

Thanks,