Hi all, is anybody knows if it possible programmat...
# suitescript
s
Hi all, is anybody knows if it possible programmatically change selected/activated tab in Client script based on user action? For example, I have checkbox, when user set it to true select/activate tab "Apply" and when user set it to false select/activate tab "Communication". I don`t need to add/remove the tabs (I already did it via userevent), just to select/activate them
r
If the tab you want to select is not a sublist but a regular tab containing custom fields, you can't directly "select" the tab in the same way you would with a sublist in SuiteScript. NetSuite's SuiteScript API doesn't provide a direct method to programmatically set focus to a non-sublist tab. However, you can simulate this action by focusing on a specific field within that tab. When the field gains focus, NetSuite's UI will automatically switch to the tab that contains the field.
Something like this const fieldChanged = (context) => { const fieldId = context.fieldId; const record = context.currentRecord; if (fieldId === 'your_trigger_field_id') { // Replace with your trigger field's ID try { // Focus on a field in the target tab const targetFieldId = 'your_target_field_id'; // Replace with your target field's ID const field = record.getField({ fieldId: targetFieldId }); if (field) { jQuery('#' + field.id).focus(); // Using jQuery to focus on the field } } catch (e) { log.error({ title: 'Error setting focus to field', details: e.message }); } } }
s
I actually found workaround solution, but I wondered if there is build in API for it. I used document.getElementByID to get Tab element in browser and then invoke click action. it looks something like this: fieldChanged(context)=>{ if(context.fieldId=='triger field'){ let e=document.getElementById('Tab which should be selected'+txt) if(e){e.click()} } } Not the most sexy method but works
👍 1
r
Yeah, that’s what my example does except mine was using jQuery instead of native JS.