Monday, June 24, 2019

C# > search > Searching for accounting periods that are not closed.

If you would like to search for a list of Accounting Periods that are not closed and return the internal id of the Accounting Period.

if (stat.isSuccess)
{
// creating search criteria
SearchBooleanField closed = new SearchBooleanField();
closed.searchValue = false;
closed.searchValueSpecified = true;

// creating an accounting period search because with the criteria
AccountingPeriodSearchBasic apsb = new AccountingPeriodSearchBasic();
apsb.closed = closed;

// Sending in the search request to NetSuite
SearchResult res = nss.search(apsb);
if (res.status.isSuccess)
{
// Returning the Results of the search to the console.
Record[] rec = res.recordList;
for (int i = 0; i < rec.Length; i++)
{
AccountingPeriod period = (AccountingPeriod)rec[i];
Console.WriteLine("Accounting Period Name: " + period.periodName);
Console.WriteLine("Account Period Internal ID: " + period.internalId);
if (period.closed == false)
{
Console.WriteLine("Accounting Period Closed: No" + '\n');
}
else
{
Console.WriteLine("Accounting Period Closed: Yes" + '\n');
}
Console.ReadKey();
}
}
}

No comments:

Post a Comment