2017-04-27 26 views
0

嘗試向NetSuite中添加新客戶,如手冊中的示例中所述。要知道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 = "[email protected]"; 
      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 = "[email protected]"; 
       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

當你調用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}"); 
    } 
}