我正在使用基於屏幕的API導入客戶。我想通過API提交時使用電子郵件地址作爲識別碼。換句話說,在提交客戶時,它將使用電子郵件地址來確定該客戶是否已經存在。Acumatica:如何使用EMAIL作爲關鍵VIA Web API插入/更新客戶?
基本上我想要完成的任務是在下面的網站,但使用基於屏幕的API,而不是: http://www.timrodman.com/importing-new-customers-email-address-acumatica/
我的代碼如下:
using (Screen context = WebServiceConnector.InitializeWebService())
{
try
{
AR303000Content customerSchema = context.AR303000GetSchema();
// ATTEMPT #1: Tried setting the CustomerID field name to "AcctCD!EMail"
customerSchema.CustomerSummary.CustomerID.FieldName += "!" + customerSchema.GeneralInfoMainContact.Email.FieldName;
// ATTEMPT #2: Tried setting the CustomerID field name to "AcctCD!Contact__eMail"
//customerSchema.CustomerSummary.CustomerID.FieldName = "AcctCD!Contact__eMail";
// Tried COMMIT = true and false
customerSchema.CustomerSummary.CustomerID.Commit = false;
// Left as default and tried "ID"
customerSchema.CustomerSummary.CustomerID.Value = "ID";
var commands = new List<Command>()
{
new Value
{
Value = customer.Email,
LinkedCommand = customerSchema.CustomerSummary.CustomerID
},
new Value
{
Value = customer.Name,
LinkedCommand = customerSchema.CustomerSummary.CustomerName
},
new Value
{
Value = customer.Class,
LinkedCommand = customerSchema.GeneralInfoFinancialSettings.CustomerClass
},
new Value
{
Value = customer.Email,
LinkedCommand = customerSchema.GeneralInfoMainContact.Email
},
new Value
{
Value = customer.CountryCode,
LinkedCommand = customerSchema.GeneralInfoMainAddress.Country
},
customerSchema.Actions.Save,
customerSchema.CustomerSummary.CustomerID
};
c = context.AR303000Submit(commands.ToArray())[0];
}
catch (Exception e)
{
}
finally
{
context.Logout();
}
}