How do I find the ID of a fieldgroup for the subli...
# ask-stanley-ai
a
How do I find the ID of a fieldgroup for the sublist.addField() function in the N/ui/serverWidget module of SuiteScript 2.1? I can find fieldgroups by label in the NetSuite UI, but how do I find their IDs?
c
AI generated answer (using internal Slack threads):
To find the ID of a field group for the sublist.addField() function in the N/ui/serverWidget module of SuiteScript 2.1, you can inspect the form's HTML. There should be a
<td>
containing the Field Group. The
id
attribute will have the Field Group's script ID, prefixed with
fg_
, e.g.
fg_custpage_grp_prompt
. However, if you're trying to add a field to a certain field group in a form on beforeLoad in the UI, you might want to use
form.insertField()
. The field you're inserting essentially inherits the field group of the location you're inserting it. Here's an example of how you might use `form.insertField()`:
Copy code
javascript
var button_field = context.form.addField({
    id: 'custpage_buttons',
    label: 'custpage_buttons',
    type: serverWidget.FieldType.INLINEHTML
}).defaultValue = button_html;

context.form.insertField(button_field, 'custrecord_results');
In this example,
custpage_buttons
is the ID of the field you're adding, and
custrecord_results
is the ID of the field you're inserting the new field in front of. Please note that the field you're inserting will go right after the field you're inserting it before, not before it. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.849902928
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.845843375
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.844537616
Please provide your feedback on this answer.