Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
Now is the time to ask your NetSuite-savvy friends and colleagues to join the NetSuite Support Community! Refer now! Click here to watch and learn more!
Stay in the Know
Be sure you're subscribed to NetSuite communication to stay in the know about monthly happenings, updates and announcements. Subscribe
Be sure you're subscribed to NetSuite communication to stay in the know about monthly happenings, updates and announcements. Subscribe
Detecting if a SalesOrder can be billed
Hello NetSuite Community!
I'm trying to write a SuiteScript that determines if a SalesOrder can be billed or not. I'd love a quick set of eyes on the script to see if I've forgotten about any details. Thanks in advance!
function canSalesOrderBeBilled(salesOrderId) { var salesOrderStatus = nlapiLookupField('salesorder', salesOrderId, 'statusRef'); if(salesOrderStatus == 'pendingBilling' || salesOrderStatus == 'pendingBillingPartFulfilled' || salesOrderStatus == 'pendingApproval') { return true; } if(salesOrderStatus == 'billed' || salesOrderStatus == 'closed' || salesOrderStatus == 'cancelled') { return false; } var filters = [ new nlobjSearchFilter('createdfrom', null, 'anyof', salesOrderId) ]; var invoiceResults = nlapiSearchRecord( 'invoice', null, filters, null ); var salesOrderResults = nlapiSearchRecord( 'cashsale', null, filters, null ); if(invoiceResults || salesOrderResults) { return false; } return true; } 0