alien4u
10/05/2021, 6:29 PMbattk
10/05/2021, 6:31 PMalien4u
10/05/2021, 6:32 PMsubsidiary
when creating the BOM(not possible).
• Set the include children checkbox after setting the Subsidiary.
• Set the defaultValue of billofmaterials
when creating the BOM Revision(not possible).
Both records are being created in Dynamic mode.alien4u
10/05/2021, 6:34 PMbattk
10/05/2021, 6:58 PMbattk
10/05/2021, 6:58 PMrequire(["N/record"], function (record) {
const oBOMRec = record.create({
type: record.Type.BOM,
isDynamic: true,
});
oBOMRec.setValue({
fieldId: "name",
value: "BOM 1",
});
oBOMRec.setValue({
fieldId: "subsidiary",
value: "1",
});
oBOMRec.setValue({
fieldId: "includechildren",
value: true,
});
oBOMRec.setValue({
fieldId: "usecomponentyield",
value: true,
});
oBOMRec.setValue({
fieldId: "availableforalllocations",
value: true,
});
const sBOMRecId = oBOMRec.save({
enableSourcing: true,
ignoreMandatoryFields: true,
});
var pEngBOMData = [{ ITEM: "5", BOM_QTY: "2" }];
/* Creating the BOM Rev */
const oBOMRevRec = record.create({
type: record.Type.BOM_REVISION,
isDynamic: true,
});
oBOMRevRec.setValue({
fieldId: "name",
value: "BOM Revision 1",
});
oBOMRevRec.setValue({
fieldId: "effectivestartdate",
value: new Date(),
});
oBOMRevRec.setValue({
fieldId: "billofmaterials",
value: sBOMRecId,
});
/* Inserting New Lines */
pEngBOMData.forEach((oBOMLine) => {
oBOMRevRec.insertLine({
sublistId: "component",
line: 0,
});
oBOMRevRec.setCurrentSublistValue({
sublistId: "component",
fieldId: "item",
value: oBOMLine.ITEM,
});
oBOMRevRec.setCurrentSublistValue({
sublistId: "component",
fieldId: "bomquantity",
value: Number(oBOMLine.BOM_QTY),
});
oBOMRevRec.commitLine({
sublistId: "component",
});
});
oBOMRevRec.save({
enableSourcing: true,
ignoreMandatoryFields: true,
});
});
battk
10/05/2021, 7:01 PMalien4u
10/05/2021, 7:01 PMalien4u
10/05/2021, 7:04 PMcomponent
sublist, if my component is only available in Subsidiary A(Not the top most/parent subsidiary) and that subsidiary is being set when creating the BOM, then I can't select that Item in the BOM Revision...alien4u
10/05/2021, 7:06 PMbattk
10/05/2021, 7:08 PMbattk
10/05/2021, 7:09 PMincludechildren
set to true means that the children of your subsidiary are also includedbattk
10/05/2021, 7:09 PMalien4u
10/05/2021, 7:26 PMalien4u
10/05/2021, 7:26 PMbattk
10/05/2021, 7:28 PMalien4u
10/05/2021, 7:29 PMCreate New Revision
from the BOM record and you will see how the BOM Revision only show the items from the top-most subsidiary.alien4u
10/05/2021, 7:30 PMbattk
10/05/2021, 7:34 PMrequire(["N/record"], function (record) {
const oBOMRec = record.create({
type: record.Type.BOM,
isDynamic: true,
});
oBOMRec.setValue({
fieldId: "name",
value: "BOM " + Date.now(),
});
oBOMRec.setValue({
fieldId: "subsidiary",
value: "10",
});
oBOMRec.setValue({
fieldId: "includechildren",
value: true,
});
oBOMRec.setValue({
fieldId: "usecomponentyield",
value: true,
});
oBOMRec.setValue({
fieldId: "availableforalllocations",
value: true,
});
const sBOMRecId = oBOMRec.save({
enableSourcing: true,
ignoreMandatoryFields: true,
});
var pEngBOMData = [{ ITEM: "306", BOM_QTY: "2" }];
/* Creating the BOM Rev */
const oBOMRevRec = record.create({
type: record.Type.BOM_REVISION,
isDynamic: true,
});
oBOMRevRec.setValue({
fieldId: "name",
value: "BOM Revision 1",
});
oBOMRevRec.setValue({
fieldId: "effectivestartdate",
value: new Date(),
});
oBOMRevRec.setValue({
fieldId: "billofmaterials",
value: sBOMRecId,
});
/* Inserting New Lines */
pEngBOMData.forEach((oBOMLine) => {
oBOMRevRec.insertLine({
sublistId: "component",
line: 0,
});
oBOMRevRec.setCurrentSublistValue({
sublistId: "component",
fieldId: "item",
value: oBOMLine.ITEM,
});
oBOMRevRec.setCurrentSublistValue({
sublistId: "component",
fieldId: "bomquantity",
value: Number(oBOMLine.BOM_QTY),
});
oBOMRevRec.commitLine({
sublistId: "component",
});
});
oBOMRevRec.save({
enableSourcing: true,
ignoreMandatoryFields: true,
});
});
battk
10/05/2021, 7:34 PMbattk
10/05/2021, 7:34 PMalien4u
10/05/2021, 7:35 PMalien4u
10/05/2021, 7:35 PMbattk
10/05/2021, 7:36 PMalien4u
10/05/2021, 7:36 PMalien4u
10/05/2021, 7:42 PMbattk
10/05/2021, 7:42 PMbattk
10/05/2021, 7:44 PM