jen
06/28/2023, 6:02 PMcontainer to specify the ID of the field group where the new field should be placed but if I include that option in the call to addField() I get an unexpected error (adding the field to the form works otherwise, but it doesn’t put it where I want). I’ve tried both with the fg_ at the start and without.
var my_new_field = context.form.addField({
id: 'custpage_my_new_field',
label: 'My New Field',
container: 'fieldGroup477'
});Nathan L
06/28/2023, 6:06 PMNathan L
06/28/2023, 6:07 PMjen
06/28/2023, 6:28 PMMTNathan
06/28/2023, 6:54 PMafterField option in insertField() in addition to nextfield though (not to mention the terribly inconsistent capitalization with what should be nextField).jen
06/28/2023, 7:14 PMjen
06/28/2023, 7:14 PMMTNathan
06/28/2023, 7:30 PMgetField() on the existing field since insertField() only takes a field object (not an ID) for the field you're moving.jen
06/28/2023, 10:30 PMDavid B
06/29/2023, 12:29 AMserverWidget.createAssistant({title:'test'}).getFieldGroupIds() to get the field group ids of the non-scripted field groups. But this resulted in an "insufficient permissions" error (on a UE script running as admin!?)
Also tried fg_fieldGroup## and fieldGroup## as the container ids.
However I can confirm using the tab id as the container does workDavid B
06/29/2023, 12:30 AMinsertField() before that
• DOM hack your scripted field into position (ugh... I know, I know.. smh..)MTNathan
06/29/2023, 1:52 PMvar scriptedField = context.form.addField({
'id':'custpage_scripted_field',
'type':serverWidget.FieldType.TEXT,
'label':'Scripted Field',
'container':'items'
});
var existingField = context.form.getField({'id':'custbody_existing_field'});
context.form.insertField({
'field':scriptedField,
'nextfield':'custbody_existing_field'
});
context.form.insertField({
'field':existingField,
'nextfield':'custpage_scripted_field'
});MTNathan
06/29/2023, 1:53 PMcontainer if it's on a tab, so maybe that's part of the issue? If it's just a field group though, I definitely have functional examples without a container specified on the addField().David B
06/29/2023, 11:12 PMcontainer parameter, just doing the double insertField() trick?David B
06/29/2023, 11:14 PMinsertField(). I wonder if the difference with Jen's testing was that they were trying to move an existing standard/native field.jen
06/29/2023, 11:25 PMjen
06/29/2023, 11:25 PMDavid B
06/29/2023, 11:40 PMinsertField() trick à la Nathan's example.
I was able to get it to work with not only an existing custom field, but also an existing standard/native fieldjen
06/29/2023, 11:59 PMjen
06/30/2023, 4:23 PMjen
06/30/2023, 4:23 PMvar ue_created_field = context.form.addField({
id: 'custpage_ue_created_field',
type: serverWidget.FieldType.LONGTEXT,
label: 'UE Created Field'
});
context.form.insertField({field: ue_created_field, nextfield: 'custrecord_existing_field_in_field_group'});
// Get existing field.
var existing_field_in_field_group = context.form.getField({fieldId: 'custrecord_existing_field_in_field_group'});
context.form.insertField({field: existing_field_in_field_group, nextfield: 'custpage_ue_created_field'});MTNathan
06/30/2023, 4:34 PMexisting_field_in_field_group - Form.getField() uses id as the option, not fieldId, so I'm guessing your field variable is null. Note that, in classic NetSuite fashion, CurrentRecord.getField() uses fieldId - that inconsistency (along with the all-lower-case nextfield) has always bothered me about this whole workaround, and both have definitely tripped me up in the past.jen
06/30/2023, 4:37 PMjen
06/30/2023, 4:37 PMjen
06/30/2023, 4:38 PMjen
06/30/2023, 4:46 PMjen
06/30/2023, 4:46 PMjen
06/30/2023, 4:47 PMNathan L
06/30/2023, 4:53 PMDavid B
07/03/2023, 4:27 AM