尝试将新客户添加到NetSuite,如手册中的示例所述。
private static void Main(string[] args)
{
ApplicationInfo _appInfo;
var service = new NetSuiteService();
service.CookieContainer = new CookieContainer();
_appInfo = new ApplicationInfo();
_appInfo.applicationId = "FB31C4F2-CA6C-4E5F-6B43-57632594F96";
service.applicationInfo = _appInfo;
var passport = new Passport();
passport.account = "5920356_SB9";
passport.email = "a@a.com";
var role = new RecordRef();
role.internalId = "3";
passport.role = role;
passport.password = "@sdkkr_5543";
try
{
var status = service.login(passport).status;
}
catch (Exception e)
{
Console.Out.WriteLine(e.Message);
throw;
}
var cust = new Customer();
cust.entityId = "XYZ Inc";
cust.altEmail = "aaa@aaa.aaa";
var response = service.add(cust);
Console.Out.WriteLine("response.status.isSuccess " + response.status.isSuccess) ;
Console.Out.WriteLine("response.status.isSuccessSpecified " + response.status.isSuccessSpecified);
service.logout();
}
结果我得到了:
response.status.isSuccess False
response.status.isSuccessSpecified True
我想客户没有插入。有什么不对,怎么知道?
答案 0 :(得分:0)
当您在服务上调用add()
时,响应包含status
属性,其中包含statusDetail
属性。 statusDetail
是由add()
产生的一系列消息(警告和错误)。您可以循环浏览这些内容,找出保存客户记录失败的原因:
var response = service.add(cust);
if (!response.status.isSuccess)
{
foreach (var error in response.status.statusDetail)
{
Console.WriteLine($"Error creating customer: {error.type} {error.message}");
}
}