Reputation: 23
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
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