Using Item Records in SuiteScript
This section includes the following topics:
For information about working with items in the UI, see Using Item Records and Item Types.
Loading Item Types
When using record.load(options), you can:
-
set the type parameter to record.Type.INVENTORY_ITEM to load the following types of item records: inventoryitem, lotnumberedinventoryitem, serializedinventoryitem
-
set the type parameter to record.Type.ASSEMBLY_ITEM to load the following types of item records: assemblyitem, lotnumberedassemblyitem, serializedassemblyitem
Filtering Items by Type
The following are valid search filter item type IDs. Note that the item filter IDs are case-sensitive.
Item Type IDs |
|
---|---|
Assembly Description Discount DwnLdItem EndGroup GiftCert Group InvtPart Kit |
Markup NonInvtPart OthCharge Payment Service ShipItem Subtotal TaxGroup TaxItem |
To use these IDs:
-
Create a script that will search for items of a specific type or types (for example, search for all non-inventory items).
-
Next, see any of the valid SuiteScript item type IDs.
Sample Code
//Create a script that will search for all non-inventory part items
function searchnoninventorypart()
{
var searchType = search.Type.NON_INVENTORY_ITEM;
var mySearch = search.create({
type: searchType,
columns: [{
name: 'internalId'
}],
filters: [{
name: ' ',
operator: search.Operator.ANYOF,
values: 'NonInvtPart'
}]
});
}
Looking Up the Subsidiary Field
The search.lookupFields(options) method lets you retrieve the current value of a field on a record. Usually, single select fields are returned as an object with value
and text
properties. Multiselect fields are returned as an object with a set of value
: text
pairs.
The subsidiary
field on an item record is a multiselect field. However, when you use search.lookupFields(options) to retrieve the value of this field, the field is returned as a single value
: text
pair instead of a set of pairs. The returned value
: text
pair represents the first subsidiary in the list.
Advanced Revenue Management Scripting with Items
The item record (internal ID item
) contains several additional accounting fields associated with the Advanced Revenue Management (Essentials) and Advanced Revenue Management (Revenue Allocation) features. The following table lists these scriptable fields.
Field |
Type |
Internal ID |
Create Revenue Plans On |
List/Record |
|
Item Revenue Category |
List/Record |
|
Revenue Allocation Group |
List/Record |
|
Revenue Recognition Rule |
List/Record |
|
The Item Revenue Category and Revenue Allocation Group fields appear only when the Advanced Revenue Management (Revenue Allocation) feature is enabled.
Before you begin working with advanced revenue management programmatically, see Setup for Advanced Revenue Management (Essentials) and Setup for Advanced Revenue Management (Revenue Allocation).
For help working with this record in the UI, see Item Configuration for Advanced Revenue Management (Essentials) and (Revenue Allocation).