saurabh bansal
saurabh bansal

Reputation: 23

Netsuite List all subsidiary items using soap webservice

I need to reference a customer to a subsidiary in netsuite. I am using c# soap api. Is there a way to loop over all subsidiary items in netsuite in c# and select the one i need.

Upvotes: 0

Views: 1357

Answers (1)

Pedro Bustos
Pedro Bustos

Reputation: 74

It would be something like this:

        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<Invoice>().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<Invoice>().ToList());
                    }
                }
            }
        }
        else
        {
            throw new Exception(string.Join(",", res.status.statusDetail.ToList()));
        }

Upvotes: 1

Related Questions