How can you programmatically detect if a period is...
# suitescript
g
How can you programmatically detect if a period is locked for just one subsidiary and not others?
I've got a restlet that creates invoices from an external POS. One subsidiary has locked AR but the others are unlocked, so the following returns true:
Copy code
function isDateInOpenPeriod(date) {
    var formattedDate = format.format({
      value: date,
      type: format.Type.DATE
    });
    var openPeriodSearch = search.create({
      type: search.Type.ACCOUNTING_PERIOD,
      filters: [
        ['closed', 'is', 'F'], 'AND',
        ['arlocked','is','F'], 'AND',
        ['startdate', 'onorbefore', formattedDate], 'AND',
        ['enddate', 'onorafter', formattedDate], 'AND',
        ["isquarter","is","F"], "AND", 
        ["isyear","is","F"]
      ],
      columns: ['internalid', 'periodname']
    });

    var result = openPeriodSearch.run().getRange({ start: 0, end: 1 });
    
    return result.length > 0;
  }
Looks like record.load won't work either. There is no subsidiary detail: https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2024_1/script/record/accountingperiod.html