salesforce API帐户创建
我们已经为Salesforce提供的WSDL文件创建了C#类 生成的大多数类都是实体类,但似乎没有任何方法可调用,例如CreateAccount或UpdateAccountsalesforce API帐户创建,salesforce,Salesforce,我们已经为Salesforce提供的WSDL文件创建了C#类 生成的大多数类都是实体类,但似乎没有任何方法可调用,例如CreateAccount或UpdateAccount 对吗?您是否使用查询直接执行所有数据操作?是的,这是正确的。这些对象中没有方法,所有操作都将使用它们的api(web服务)完成 是Java和C中的一些示例代码35;是的,这是正确的。这些对象中没有方法,所有操作都将使用它们的api(web服务)完成 是Java和C中的一些示例代码35;大多数类,如Account、Contac
对吗?您是否使用查询直接执行所有数据操作?是的,这是正确的。这些对象中没有方法,所有操作都将使用它们的api(web服务)完成
是Java和C中的一些示例代码35;是的,这是正确的。这些对象中没有方法,所有操作都将使用它们的api(web服务)完成
是Java和C中的一些示例代码35;大多数类,如Account、Contact等,实际上都是经过连接的数据结构。SforceService(如果您使用的是web引用,不确定WCF调用的是什么类)是使用它们进行操作的入口点,例如,您可以将帐户列表传递给create方法,以便在salesforce端创建帐户,在中有许多示例。
查询是只读的,您不能通过查询调用进行更改。大多数类,如Account、Contact等,实际上只是通过网络传输的数据结构。SforceService(如果您使用的是web引用,不确定WCF调用的是什么类)是使用它们进行操作的入口点,例如,您可以将帐户列表传递给create方法,以便在salesforce端创建帐户,在中有许多示例。
查询是只读的,您不能通过查询调用进行更改。Salesforce为每个对象提供了单独的创建方法,它提供了一种通用的创建方法,可接受类型为account或contact或任何自定义对象的通用对象的输入
/// Demonstrates how to create one or more Account records via the API
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.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
sObject[] accounts = new sObject[2];
// Add the accounts to the SObject array
accounts[0] = account1;
accounts[1] = account2;
// Invoke the create() call
try
{
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
foreach (Error error in saveResults[i].errors)
{
Console.WriteLine("Error code is: {0}",
error.statusCode.ToString());
Console.WriteLine("Error message: {0}", error.message);
}
}
}
}
catch (SoapException e)
{
Console.WriteLine(e.Code);
Console.WriteLine(e.Message);
}
} `
///演示如何通过API创建一个或多个帐户记录
public void CreateAccountSample()
{
账户1=新账户();
账户account2=新账户();
//在account1对象上设置一些字段。未设置名称字段
//因此,该记录应该失败,因为它是必填字段。
account1.BillingCity=“Wichita”;
account1.BillingCountry=“美国”;
account1.BillingState=“KA”;
account1.BillingStreet=“4322 Haystack大道”;
account1.BillingPostalCode=“87901”;
//在account2对象上设置一些字段
account2.Name=“Golden Straw”;
account2.BillingCity=“奥克兰”;
account2.BillingCountry=“美国”;
account2.BillingState=“CA”;
account2.BillingStreet=“666袭击者大道”;
account2.BillingPostalCode=“97502”;
//创建一个Sobject数组以保存帐户
sObject[]账户=新的sObject[2];
//将帐户添加到SObject数组
账户[0]=账户1;
账户[1]=账户2;
//调用create()调用
尝试
{
SaveResult[]saveResults=binding.create(账户);
//处理结果
for(int i=0;i
Salesforce提供了一种通用的创建方法,它不为每个对象提供单独的创建方法,而是接受通用对象的输入,该对象的类型可以是account、contact或任何自定义对象
/// Demonstrates how to create one or more Account records via the API
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.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
sObject[] accounts = new sObject[2];
// Add the accounts to the SObject array
accounts[0] = account1;
accounts[1] = account2;
// Invoke the create() call
try
{
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
foreach (Error error in saveResults[i].errors)
{
Console.WriteLine("Error code is: {0}",
error.statusCode.ToString());
Console.WriteLine("Error message: {0}", error.message);
}
}
}
}
catch (SoapException e)
{
Console.WriteLine(e.Code);
Console.WriteLine(e.Message);
}
} `
///演示如何通过API创建一个或多个帐户记录
public void CreateAccountSample()
{
账户1=新账户();
账户account2=新账户();
//在account1对象上设置一些字段。未设置名称字段
//因此,该记录应该失败,因为它是必填字段。
account1.BillingCity=“Wichita”;
account1.BillingCountry=“美国”;
account1.BillingState=“KA”;
account1.BillingStreet=“4322 Haystack大道”;
account1.BillingPostalCode=“87901”;
//在account2对象上设置一些字段
account2.Name=“Golden Straw”;
account2.BillingCity=“奥克兰”;
account2.BillingCountry=“美国”;
account2.BillingState=“CA”;
account2.BillingStreet=“666袭击者大道”;
account2.BillingPostalCode=“97502”;
//创建一个Sobject数组以保存帐户
sObject[]账户=新的sObject[2];
//将帐户添加到SObject数组
账户[0]=账户1;
账户[1]=账户2;
//调用create()调用
尝试
{
SaveResult[]saveResults=binding.create(账户);
//处理结果
for(int i=0;i