如何使用.net从Netsuite(suitalk)webservice检索公司信息?

时间:2016-11-15 04:43:37

标签: .net netsuite

尝试通过Setup->Company information访问Account实体来获取AccountID下的数据(公司名称,地址,雇主识别码)。

RecordRef recordRef = new RecordRef();  
recordRef.externalId = "TSTDRV1531161";  
recordRef.type = RecordType.account;  
recordRef.typeSpecified = true;  
ReadResponse response = _service.get(recordRef);

不会返回任何结果。我怎样才能得到这些信息?

1 个答案:

答案 0 :(得分:0)

试试这个

        var sub = new SubsidiarySearchBasic();
        var res = netSuiteService.search(sub);

        if (res.status.isSuccess)
        {
            if (res.totalPages == res.pageIndex)
            { 
                var result = res.recordList.ToList().Any() ? res.recordList.ToList().Cast<Subsidiary>().ToList() : null;
            }
            else
            {
                var resultados = res.recordList.ToList().Cast<Subsidiary>().ToList();

                for (var i = 2; i <= res.totalPages; i++)
                {
                    var resPages = netSuiteService.searchMoreWithId(res.searchId, i);

                    if (resPages.status.isSuccess)
                        resultados.AddRange(res.recordList.ToList().Cast<Subsidiary>().ToList());
                }
            }
        }
        else
            throw new Exception(string.Join(",", res.status.statusDetail.ToList()));