wes_w
02/22/2023, 6:41 PMclass SalesOrder extends so.SalesOrderBase {
@FieldType.sublist(so.ItemSublist)
// define a strongly typed item sublist
item : Sublist<so.ItemSublist>
}
var salesorder = new SalesOrder(1234)
salesorder.item // already a collection of line items with fields defined by so.ItemSublist
If I want to add 'shipgroup' for example, how would I go about that?Shawn Talbert
02/22/2023, 6:56 PMSublistLine
base type and add your fields there. There is a similar example for a Customer
record and a sublist here https://exploreconsulting.github.io/netsuite-fasttrack-toolkit-ss2/#overview-exampleShawn Talbert
02/22/2023, 7:06 PMShawn Talbert
02/22/2023, 7:08 PMShawn Talbert
02/22/2023, 7:09 PMshipgroup
as a field on the item
sublist so I assume it's the entire shipgroup sublist you really want?wes_w
02/22/2023, 7:09 PMShawn Talbert
02/22/2023, 7:11 PMInventoryDetailBase
is already defined so you should be able to subclass the so.ItemSublist and add inventorydetail
as a propertyShawn Talbert
02/22/2023, 7:12 PMwes_w
02/22/2023, 7:12 PMShawn Talbert
02/22/2023, 7:15 PMwes_w
02/22/2023, 7:16 PMwes_w
02/22/2023, 7:17 PMShawn Talbert
02/22/2023, 7:34 PMSalesOrder.ts
would look something like this.wes_w
02/22/2023, 7:34 PMShawn Talbert
02/22/2023, 7:35 PMRecordTypes
so it would live in RecordTypes/SalesOrder.ts
wes_w
02/22/2023, 7:36 PMwes_w
02/22/2023, 7:36 PMShawn Talbert
02/22/2023, 7:36 PMwes_w
02/22/2023, 7:36 PMShawn Talbert
02/22/2023, 7:37 PMimport {SalesOrder} from 'RecordTypes/SalesOrder'
wes_w
02/22/2023, 7:37 PMShawn Talbert
02/22/2023, 7:37 PMconst so = new SalesOrder(123)
wes_w
02/22/2023, 7:37 PMwes_w
02/22/2023, 7:38 PMShawn Talbert
02/22/2023, 7:38 PMShawn Talbert
02/22/2023, 7:39 PMwes_w
02/22/2023, 7:39 PMShawn Talbert
02/22/2023, 7:40 PMwes_w
02/22/2023, 7:41 PMShawn Talbert
02/22/2023, 7:43 PMwes_w
02/22/2023, 7:43 PMShawn Talbert
02/22/2023, 7:44 PM_.sortBy()
wes_w
02/22/2023, 7:44 PMShawn Talbert
02/22/2023, 7:45 PMwes_w
02/22/2023, 8:16 PM{
"type": "error.SuiteScriptError",
"name": "FIELD_1_IS_NOT_A_SUBRECORD_FIELD",
"message": "Field inventorydetail is not a subrecord field.",
"stack": [
"Error",
" at Object.onRequest (/SuiteScripts/PickingTicketV2/pickingticketV2.js:63:29)"
],
"cause": {
"name": "FIELD_1_IS_NOT_A_SUBRECORD_FIELD",
"message": "Field inventorydetail is not a subrecord field.",
"notifyOff": true
},
"id": "",
"notifyOff": true,
"userFacing": true
}
Not a subrecord fieldShawn Talbert
02/22/2023, 10:40 PMShawn Talbert
02/22/2023, 10:41 PMSalesOrder.ts
we can take a lookwes_w
02/23/2023, 2:26 PMimport { SalesOrderBase, ItemSublist as SalesOrderItemSublist } from '/SuiteScripts/NFT-SS2-7.1.0/DataAccess/SalesOrderBase'
import { Sublist, SublistFieldType, SublistLine } from '/SuiteScripts/NFT-SS2-7.1.0/DataAccess/Sublist'
import { FieldType } from '/SuiteScripts/NFT-SS2-7.1.0/DataAccess/Record'
import { InventoryDetailBase } from '/SuiteScripts/NFT-SS2-7.1.0/DataAccess/InventoryDetailBase'
export class ItemSublist extends SalesOrderItemSublist {
// shipgroup: string
@FieldType.subrecord(InventoryDetailBase)
inventorydetail: InventoryDetailBase
}
export class ShipGroupSublist extends SublistLine {
@SublistFieldType.float
weight: number
@SublistFieldType.freeformtext
destinationaddress: string
@SublistFieldType.freeformtext
id: string
@SublistFieldType.freeformtext
shippingcarrier: string
@SublistFieldType.freeformtext
shippingmethod: string
}
export class SalesOrder extends SalesOrderBase {
@FieldType.sublist(ShipGroupSublist)
shipgroup: Sublist<ShipGroupSublist>
@FieldType.sublist(ItemSublist)
item: Sublist<ItemSublist>
}
wes_w
02/23/2023, 2:27 PMShawn Talbert
02/23/2023, 2:37 PMshipgroup
field on the item sublist https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2022_2/script/record/salesorder.htmlShawn Talbert
02/23/2023, 2:38 PMShawn Talbert
02/23/2023, 2:43 PMshipgroup
needs the Multiple Ship To feature but don't quote me on that.Shawn Talbert
02/23/2023, 2:44 PMwes_w
02/23/2023, 2:46 PMwes_w
02/23/2023, 2:48 PMfunction getInvDetail(record,i) { //Returns Array of serial numbers from inventorydetail subrecord
record.selectLineItem('item', i);
var strItem = record.getCurrentLineItemValue('item', 'item');
nlapiLogExecution("DEBUG", "strItem", strItem);
var intCommitted = record.getCurrentLineItemValue('item', 'quantitycommitted');
nlapiLogExecution("DEBUG", "intCommitted", intCommitted);
var invDetailSubrecord = record.viewCurrentLineItemSubrecord('item', 'inventorydetail');
nlapiLogExecution("DEBUG", "invDetailSubrecord", record.viewCurrentLineItemSubrecord('item', 'inventorydetail'));
if (invDetailSubrecord != null) {
try {
var cnt = invDetailSubrecord.getLineItemCount('inventoryassignment');
nlapiLogExecution("DEBUG", "invDetailSubrecord, cnt", invDetailSubrecord + ', ' + cnt);
//Get the serial/lot number details
var sn = [];
var a = 0;
for (var j = 1; j <= cnt; j++) {
invDetailSubrecord.selectLineItem('inventoryassignment', j);
var serialno = invDetailSubrecord.getCurrentLineItemValue('inventoryassignment', 'issueinventorynumber');
if (serialno) {
var strSerial = nlapiLookupField('inventorynumber', serialno, 'inventorynumber');
nlapiLogExecution('DEBUG', 'Serial# : ' + strSerial);
sn.push(nlapiEscapeXML(strSerial));
nlapiLogExecution("DEBUG", 'sn, typeof', sn + ', ' + typeof (sn));
//nlapiLogExecution("DEBUG",'receipt #: ' + invDetailSubrecord.getCurrentLineItemValue('inventoryassignment','receiptinventorynumber') + ', invassign line# ' + j);
//nlapiLogExecution("DEBUG",'issue #: ' + invDetailSubrecord.getCurrentLineItemValue('inventoryassignment','issueinventorynumber'));
}
}
return sn;
}
wes_w
02/23/2023, 2:55 PM[
{
"item": "3932",
"inventorydetailavail": "T",
"isserial": "F",
"item_display": "3002PGGMN",
"shipgroup": "1",
"quantitycommitted": "1700",
"isnumbered": "T",
"fulfillable": "true",
"description": "iClass 16K/16 SE Access Card- J.O'Brien Stock Cards",
"units_display": "ea",
"rate": "5.39",
"quantity": "2500",
"itemtype": "InvtPart",
"location": "3"
},
{
"item": "3952",
"inventorydetailavail": "T",
"isserial": "F",
"item_display": "MC-1000",
"shipgroup": "1",
"quantitycommitted": "1700",
"isnumbered": "T",
"fulfillable": "true",
"description": "Corporate 1000 Maintenance Fee",
"units_display": "ea",
"quantity": "2500",
"itemtype": "InvtPart",
"location": "3"
},
{
"item": "3331",
"inventorydetailavail": "F",
"isserial": "F",
"item_display": "8555",
"shipgroup": "2",
"isnumbered": "F",
"fulfillable": "true",
"description": "Economy Vinyl Strap Clip",
"units_display": "pk100",
"rate": "12",
"quantity": "2500",
"itemtype": "InvtPart",
"location": "1"
},
{
"item": "109285",
"inventorydetailavail": "F",
"isserial": "F",
"item_display": "Molex 5/8 Custom Lanyard with All Plastic Clip",
"shipgroup": "3",
"isnumbered": "F",
"fulfillable": "true",
"description": "Custom Printed 5/8 Inch Tubular Silk Screened Lanyard, 2 Side, 1 Color, Breakaway with All Plastic Clip, Red",
"units_display": "ea",
"rate": "1.92",
"quantity": "2500",
"itemtype": "InvtPart",
"location": "3"
}
]
wes_w
02/23/2023, 2:56 PMShawn Talbert
02/23/2023, 3:36 PMRecord
that's actually undefined and unsupported - in other words you cannot rely on that output as it's not part of the NetSuite APIShawn Talbert
02/23/2023, 3:39 PMinventorydetail
and inventoryassignment
this way without issue. It's quite pleasant actually to be able to access the main record, subrecord, and subrecord sublist all with simple dot notation and/or lodash methods.wes_w
02/24/2023, 4:39 PMProperty sublist does not exist on typeof SublistFieldType
import {SalesOrderBase, ItemSublist as SalesOrderItemSublist} from '/SuiteScripts/NFT-SS2-7.1.0/DataAccess/SalesOrderBase'
import {Sublist, SublistFieldType, SublistLine} from '/SuiteScripts/NFT-SS2-7.1.0/DataAccess/Sublist'
import {FieldType} from '/SuiteScripts/NFT-SS2-7.1.0/DataAccess/Record'
import {InventoryDetailBase, InventoryAssignmentSublist} from '/SuiteScripts/NFT-SS2-7.1.0/DataAccess/InventoryDetailBase'
export class InventoryDetail extends InventoryDetailBase {
@FieldType.freeformtext
inventoryassignmentText: string
}
/**
* 'member' sublist
*/
export class MemberSublist extends SublistLine {
item: string;
memberdescr: string;
memberunit: string;
quantity: number;
}
export class ItemSublist extends SalesOrderItemSublist {
@SublistFieldType.sublist //Property sublist does not exist on typeof SublistFieldType
member: Sublist<MemberSublist>
@SublistFieldType.freeformtext
shipgroup: string
@SublistFieldType.freeformtext
item_display: string
@SublistFieldType.checkbox
isserial: boolean
@SublistFieldType.checkbox
isnumbered: boolean
@SublistFieldType.freeformtext
serialnumbers: string
@SublistFieldType.checkbox
inventorydetailavail: boolean
@SublistFieldType.subrecord(InventoryDetail)
inventorydetail: InventoryDetail
}
Any thoughts?Shawn Talbert
02/24/2023, 4:42 PMShawn Talbert
02/24/2023, 4:45 PMmember
being a sublist on the (documented)`item` sublist? (I don't see it in the records browser)wes_w
02/24/2023, 4:53 PMShawn Talbert
02/24/2023, 4:54 PMmember
sublistShawn Talbert
02/24/2023, 4:55 PMexport class AssemblyItem extends AssemblyItemBase {}
and maybe you're all set.wes_w
02/24/2023, 4:57 PMwes_w
02/24/2023, 4:57 PMShawn Talbert
02/24/2023, 4:59 PMexport class KitItem extends Item {...}
wes_w
02/24/2023, 5:00 PMwes_w
02/24/2023, 5:00 PMShawn Talbert
02/24/2023, 5:02 PMitem
sublist lines are NOT item records. But take a look at itemtype
on that sublistShawn Talbert
02/24/2023, 5:03 PMmember
sublistwes_w
02/24/2023, 5:04 PMShawn Talbert
02/24/2023, 5:05 PMnew SalesOrder(123)
it's loading NS sales order record 123 - it's really just a thin wrapper around the native NS apiwes_w
02/24/2023, 5:06 PMShawn Talbert
02/24/2023, 5:07 PMwes_w
02/24/2023, 5:07 PMShawn Talbert
02/24/2023, 5:09 PMShawn Talbert
02/24/2023, 5:09 PMShawn Talbert
02/24/2023, 5:10 PMShawn Talbert
02/24/2023, 5:11 PMwes_w
02/24/2023, 5:11 PMShawn Talbert
02/24/2023, 5:12 PMautoLogMethodEntryExit
Shawn Talbert
02/24/2023, 5:12 PMwithGovernance
etc.)Shawn Talbert
02/24/2023, 5:35 PMexport
from the X
namespace will get autologged. So, we break our problems into functions, then export them on X
to get automagic autologging