This article is relevant if you are trying to set the default tab on a built-in NetSuite form.
Background
NetSuite’s default forms offer good point and click customizations capacities. But it does not have a built-in point-and-click mechanism to set which default tab shows when a form loads. In the case of our NetSuite Systems Integration practice, since our client invoice work is primarily based on Timesheet information, we want the “Billable Time” subtab under the “Items” Tab to show up first. This will save us a click each time we work with the form.
To figure out how to do this, the trick is to understand that NetSuite is responding to your browser clicks. Use your Brower’s Developer Mode to inspect the tab and understand what NetSuite’s scripts are doing when you click. You then want to effectively do the same thing when the web page (form) fully loads.
Create a Before Load User Event
The following SuiteScript function assumes that you understand how to create a Before Load User Event and you have some basic understanding of development on the NetSuite platform. You may want to reference a previous article that offers more background about loading Javascript in NetSuite client side forms.
function id001_InvoiceUserEventBeforeLoad(type, form, request){ if (type == 'delete' || type == 'view'){ return; }; //Since the majority of our work is in timesheet billing, make it the default tab. //Note, it is important that the entire page loads before calling our custom function. //Hence, bind our function to the window onload event var sTab = 'time'; //determine default sub tab and set value here. html = ''; html += '<SCRIPT language="JavaScript" type="text/javascript">\r\n'; html += "function bindEvent(element, type, handler) {if(element.addEventListener) {element.addEventListener(type, handler, false);} else {element.attachEvent('on'+type, handler);}} \r\n"; html += "function wload() \r\n{\r\n"; html += 'window.shownmachine ="' + sTab + '";ShowitemsMachine("' +sTab + '");\r\n'; html += "}\r\n"; html += '</SCRIPT>\r\n'; html += '<SCRIPT language="JavaScript" type="text/javascript">\r\n'; html += 'bindEvent(window, "load", wload);\r\n'; html += '</SCRIPT>\r\n'; var field0 = form.addField('custpage_set_default_tab', 'inlinehtml', ''); field0.setDefaultValue(html); };
Enhance NetSuite
We love to innovate on the NetSuite platform. If you want to get more out of your NetSuite investment, contact us.