Group
You use the group record to define groups of contacts, customers, employees, partners, or vendors.
The internal ID for this record is entitygroup
.
In the UI, you access this record at Lists > Relationships > Group > New.
For help working with this record in the UI, see Working with Groups.
See the SuiteScript Records Browser for all internal IDs associated with this record.
For information about using the SuiteScript Records Browser, see Working with the SuiteScript Records Browser in the NetSuite Help Center.
For information about scripting with this record in SuiteScript, see the following help topics:
Supported Script Types
The group record is scriptable in server SuiteScript only. None of the user events are supported.
Supported Functions
This record is fully scriptable, which means it can be created, read, updated, deleted, and searched.
Usage Notes
Be aware of the following details when working with this record:
-
The grouptype field is required and must be set either to “static” or “dynamic.”
-
If the grouptype is dynamic, you can never manually add to the Members sublist (because the group members are determined by a saved search). This behavior is the same as in the UI.
-
If the grouptype is static, you can create lines in the Members sublist during the time that you are creating the record, but you cannot modify the sublist during updates. This behavior differs from the UI, which does allow manual updates after the record is created.
To add members to a group in SuiteScript after it has been created, you can use code like the following:
record.attach({ record: { type: record.Type.CUSTOMER, id: <someCustomerId> }, to: { type: 'entitygroup', id: <someGroupId> } }); record.detach({ record: { type: record.Type.CUSTOMER, id: <someCustomerId> }, from: { type: 'entitygroup', id: <someGroupId> } });
Code Sample
The following sample shows how to create a static group record.
var initValues = new Array();
initValues.grouptype = 'Employee';
initValues.dynamic = 'false';
var staticRecGroup = record.create({
type: 'entitygroup',
defaultValues: initValues
});
staticRecGroup.setValue({
fieldId: 'groupname',
value: 'WC1'
});
staticRecGroup.setValue({
fieldId: 'subsidiary',
value: '1'
});
staticRecGroup.setValue({
fieldId: 'ismanufacturingworkcenter',
value: true
});
staticRecGroup.setValue({
fieldId: 'machineresources',
value: '11'
});
staticRecGroup.setValue({
fieldId: 'laborresources',
value: '22'
});
var recId = staticRecGroup.save();