You need to sign in to do that
Don't have an account?
Vimal Bhavsar 6
Create Account/Contact from asp.net C# Application with the help of Enterprise WSDL API file.
Hi Team,
I got the code for Update the Account/Contact Object data from the C# application with the help of Enterprise WSDL API from the Salesforce here my code :
binding.QueryOptionsValue = new QueryOptions();
binding.QueryOptionsValue.batchSize = 250;
binding.QueryOptionsValue.batchSizeSpecified = true;
Account[] updates = new Account[2];
Account account1 = new Account();
account1.Id = "0019000000zSW2e";
account1.ShippingPostalCode = "89044";
updates[0] = account1;
//Account account2 = new Account();
//account2.Id = ids[1];
//account2.NumberOfEmployees = 1000;
//updates[1] = account2;
// Invoke the update call and save the results
try
{
SaveResult[] saveResults = binding.update(updates);
foreach (SaveResult saveResult in saveResults)
{
if (saveResult.success)
{
Console.WriteLine("Successfully updated Account ID: " +
saveResult.id);
}
else
{
// Handle the errors.
// We just print the first error out for sample purposes.
Error[] errors = saveResult.errors;
if (errors.Length > 0)
{
Console.WriteLine("Error: could not update " +
"Account ID " + saveResult.id + "."
);
Console.WriteLine("\tThe error reported was: (" +
errors[0].statusCode + ") " +
errors[0].message + "."
);
}
}
}
}
catch (Exception e)
{
Console.WriteLine("An unexpected error has occurred: " +
e.Message + "\n" + e.StackTrace);
}
Console.ReadLine();
-------------------------------------------------------------------------------------------------------------------------------------------------------
When i use the code for create the Account/Contact in salsforce i change littlebit this code and try to create but it's not working here is my that code
public void CreateAccountSample()
{
Account account1 = new Account();
Account account2 = new Account();
// Set some fields on the account1 object. Name field is not set
// so this record should fail as it is a required field.
account1.Name = "Golden";
account1.BillingCity = "Wichita";
account1.BillingCountry = "US";
account1.BillingState = "KA";
account1.BillingStreet = "4322 Haystack Boulevard";
account1.BillingPostalCode = "87901";
// Set some fields on the account2 object
account2.Name = "Golden Straw";
account2.BillingCity = "Oakland";
account2.BillingCountry = "US";
account2.BillingState = "CA";
account2.BillingStreet = "666 Raiders Boulevard";
account2.BillingPostalCode = "97502";
// Create an array of SObjects to hold the accounts
WebReference.sObject[] accounts = new WebReference.sObject[2];
// Add the accounts to the SObject array
accounts[0] = account1;
accounts[1] = account2;
// Invoke the create() call
try
{
WebReference.SaveResult[] saveResults = binding.create(accounts);
// Handle the results
for (int i = 0; i < saveResults.Length; i++)
{
// Determine whether create() succeeded or had errors
if (saveResults[i].success)
{
// No errors, so retrieve the Id created for this record
Console.WriteLine("An Account was created with Id: {0}",
saveResults[i].id);
}
else
{
Console.WriteLine("Item {0} had an error updating", i);
// Handle the errors
}
}
}
catch (Exception e)
{
// Console.WriteLine(e.Code);
//Console.WriteLine(e.Message);
Response.Write(e);
throw e;
}
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Can any one plese help me for the same?
I got the code for Update the Account/Contact Object data from the C# application with the help of Enterprise WSDL API from the Salesforce here my code :
binding.QueryOptionsValue = new QueryOptions();
binding.QueryOptionsValue.batchSize = 250;
binding.QueryOptionsValue.batchSizeSpecified = true;
Account[] updates = new Account[2];
Account account1 = new Account();
account1.Id = "0019000000zSW2e";
account1.ShippingPostalCode = "89044";
updates[0] = account1;
//Account account2 = new Account();
//account2.Id = ids[1];
//account2.NumberOfEmployees = 1000;
//updates[1] = account2;
// Invoke the update call and save the results
try
{
SaveResult[] saveResults = binding.update(updates);
foreach (SaveResult saveResult in saveResults)
{
if (saveResult.success)
{
Console.WriteLine("Successfully updated Account ID: " +
saveResult.id);
}
else
{
// Handle the errors.
// We just print the first error out for sample purposes.
Error[] errors = saveResult.errors;
if (errors.Length > 0)
{
Console.WriteLine("Error: could not update " +
"Account ID " + saveResult.id + "."
);
Console.WriteLine("\tThe error reported was: (" +
errors[0].statusCode + ") " +
errors[0].message + "."
);
}
}
}
}
catch (Exception e)
{
Console.WriteLine("An unexpected error has occurred: " +
e.Message + "\n" + e.StackTrace);
}
Console.ReadLine();
-------------------------------------------------------------------------------------------------------------------------------------------------------
When i use the code for create the Account/Contact in salsforce i change littlebit this code and try to create but it's not working here is my that code
public void CreateAccountSample()
{
Account account1 = new Account();
Account account2 = new Account();
// Set some fields on the account1 object. Name field is not set
// so this record should fail as it is a required field.
account1.Name = "Golden";
account1.BillingCity = "Wichita";
account1.BillingCountry = "US";
account1.BillingState = "KA";
account1.BillingStreet = "4322 Haystack Boulevard";
account1.BillingPostalCode = "87901";
// Set some fields on the account2 object
account2.Name = "Golden Straw";
account2.BillingCity = "Oakland";
account2.BillingCountry = "US";
account2.BillingState = "CA";
account2.BillingStreet = "666 Raiders Boulevard";
account2.BillingPostalCode = "97502";
// Create an array of SObjects to hold the accounts
WebReference.sObject[] accounts = new WebReference.sObject[2];
// Add the accounts to the SObject array
accounts[0] = account1;
accounts[1] = account2;
// Invoke the create() call
try
{
WebReference.SaveResult[] saveResults = binding.create(accounts);
// Handle the results
for (int i = 0; i < saveResults.Length; i++)
{
// Determine whether create() succeeded or had errors
if (saveResults[i].success)
{
// No errors, so retrieve the Id created for this record
Console.WriteLine("An Account was created with Id: {0}",
saveResults[i].id);
}
else
{
Console.WriteLine("Item {0} had an error updating", i);
// Handle the errors
}
}
}
catch (Exception e)
{
// Console.WriteLine(e.Code);
//Console.WriteLine(e.Message);
Response.Write(e);
throw e;
}
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Can any one plese help me for the same?