0

I have the following code:

var search = new TransactionSearchAdvanced();
search.savedSearchId = "680";
SearchResult searchResult = Client.Service.search(search);
var resultList = searchResult.searchRowList;
var castList = resultList.Cast<TransactionSearchRow>(); 

Everytime I call this method I get 0 search results returned. If I view the saved search in NetSuite itself I have over 1000 results.

I am running a similar search on customers that is 100% working.

public static List<Account> GetCustomerList()
{
    var search = new CustomerSearchAdvanced();
    search.savedSearchId = "678";

    try
    {
        SearchResult searchResult = Client.Service.search(search);
        var resultList = searchResult.searchRowList;
        var castList = resultList.Cast<CustomerSearchRow>();
        var accountList = new List<Account>();

        foreach (var resultRow in castList)
        {
            var basic = resultRow.basic;

            var account = new Account();

            account.NsAccountId = basic.entityId?.FirstOrDefault()?.searchValue;
            account.Name = basic.companyName?.FirstOrDefault()?.searchValue;
            account.EmailAddress1 = basic.email?.FirstOrDefault()?.searchValue;
            account.Address = basic.address?.FirstOrDefault()?.searchValue;
            account.BillingAddress = basic.billAddress?.FirstOrDefault()?.searchValue;
            account.Telephone1 = basic.phone?.FirstOrDefault()?.searchValue;
            account.BillingPhone = basic.billPhone?.FirstOrDefault()?.searchValue;
            account.Fax = basic.fax?.FirstOrDefault()?.searchValue;
            account.WebAddress = basic.url?.FirstOrDefault()?.searchValue;

            accountList.Add(account);
        }

        return accountList;
    }

I have tried adding the the role to view transactions. I am totally unfamiliar with netsuite itself and have no idea what it could be since all the settings on my 2 searches are identical.

EDIT The SearchResult objects are actually different: enter image description here

enter image description here

looking into this now

Cœur
  • 37,241
  • 25
  • 195
  • 267
D4RKCIDE
  • 3,439
  • 1
  • 18
  • 34
  • Without being able to step through your code in debug, I can only guess. And my guess is that the problem is here: `var castList = resultList.Cast();`. Question: What is the value of `searchResult ` after this line: `SearchResult searchResult = Client.Service.search(search);` – Casey Crookston Dec 03 '19 at 17:36
  • Thanks for the response. The cast works fine for customer `var castList = resultList.Cast();` the values are the same between the 2 searches, except the transaction search has 0 rows. and the customer search has rows – D4RKCIDE Dec 03 '19 at 17:41
  • Ok, so just so I'm clear, after this line: `SearchResult searchResult = Client.Service.search(search);` for Search Id of 680, does `searchResult ` have results in it? Or is the count 0? – Casey Crookston Dec 03 '19 at 17:43
  • The count is always 0 – D4RKCIDE Dec 03 '19 at 17:48
  • Ok, but for search id of 678, the same line `SearchResult searchResult = Client.Service.search(search);` will get results. Is that correct? – Casey Crookston Dec 03 '19 at 17:56
  • Yes I have over 600 rows for that search. Thank you for taking a look at this for me :) – D4RKCIDE Dec 03 '19 at 17:57
  • Don't thank me yet! If `Client.Service.search()` works for `CustomerSearchAdvanced` (id of 678) but not for `TransactionSearchAdvanced` (id of 680) then I suspect the problem is not in the code you've shown in your post. I think you need to dig into `Client.Service.search()` (assuming you can?) Or, take a look at both `CustomerSearchAdvanced` and `TransactionSearchAdvanced` to see why one works and the other doesn't. – Casey Crookston Dec 03 '19 at 18:02
  • Digging into those pieces now! – D4RKCIDE Dec 03 '19 at 18:09

1 Answers1

3

In the saved search interface of NetSuite there is a field that needs to be chacked "Run Unrestricted" this is what solved it for me.

enter image description here

D4RKCIDE
  • 3,439
  • 1
  • 18
  • 34