EAGLE
11/24/2022, 1:36 PMbattk
11/24/2022, 2:10 PMbattk
11/24/2022, 2:10 PMbattk
11/24/2022, 2:11 PMEAGLE
11/24/2022, 2:34 PMEAGLE
11/24/2022, 2:36 PMbattk
11/24/2022, 2:37 PMbattk
11/24/2022, 2:38 PMbattk
11/24/2022, 2:38 PMbattk
11/24/2022, 2:39 PMEAGLE
11/24/2022, 2:48 PMEAGLE
11/24/2022, 2:49 PM/**
*@NApiVersion 2.1
*@NScriptType userEventScript
*/
define(["N/record","N/url"], function (record,url){
function afterSubmit(context){
try {
log.debug("!--- Save Record Start--!");
var currentRec = context.newRecord;
var objRecord = record.create({
type: record.Type.INVENTORY_ADJUSTMENT,
});
var recordObject = {};
var client = currentRec.getValue({ fieldId: "entity" });
if (client) {
objRecord.setValue({ fieldId: "customer", value: client });
}
var date = currentRec.getValue({ fieldId: "trandate" });
if (date) {
objRecord.setValue({ fieldId: "trandate", value: new Date(date) });
}
var memo = currentRec.getValue({ fieldId: "memo" });
if (memo) {
objRecord.setValue({ fieldId: "memo", value: memo });
}
var department = currentRec.getValue({ fieldId: "department" });
if (department) {
objRecord.setValue({ fieldId: "department", value: department });
}
var location = currentRec.getValue({ fieldId: "location" });
if (location) {
objRecord.setValue({ fieldId: "adjlocation", value: location });
}
var adjustAccount = currentRec.getValue({
fieldId: "custbody_gbs_ir_adjust_acct",
});
if (adjustAccount) {
objRecord.setValue({ fieldId: "account", value: adjustAccount });
}
var sublistCount = currentRec.getLineCount({
sublistId: "item",
});
log.debug("sublistCount 111", sublistCount);
for (var i = 0; i < sublistCount; i++) {
var item = currentRec.getSublistValue({
sublistId: "item",
fieldId: "item",
line: i,
});
if (item) {
objRecord.setSublistValue({
sublistId: "inventory",
fieldId: "item",
value: item,
line: i,
forceSyncSourcing: true,
});
objRecord.setSublistValue({
sublistId: "inventory",
fieldId: "location",
value: location,
line: i,
forceSyncSourcing: true,
});
objRecord.setSublistValue({
sublistId: "inventory",
fieldId: "department",
value: department,
line: i,
});
}
var adjustQuanty = currentRec.getSublistValue({
sublistId: "item",
fieldId: "quantity",
line: i,
});
log.debug("adjustQuanty 146", adjustQuanty);
if (adjustQuanty) {
log.debug("adjustQuanty 147", adjustQuanty);
objRecord.setSublistValue({
sublistId: "inventory",
fieldId: "adjustqtyby",
value: adjustQuanty,
line: i,
forceSyncSourcing: true,
});
}
log.debug("item", item);
var units = currentRec.getSublistValue({
sublistId: "item",
fieldId: "units",
line: i,
});
if (units) {
objRecord.setSublistValue({
sublistId: "inventory",
fieldId: "units",
value: units,
line: i,
});
}
var memo = currentRec.getSublistValue({
sublistId: "item",
fieldId: "memo",
line: i,
});
if (memo) {
objRecord.setSublistValue({
sublistId: "inventory",
fieldId: "item",
value: memo,
line: i,
});
}
log.debug("memo", memo);
var hasSublistSubrec = currentRec.hasSublistSubrecord({
sublistId: "item",
fieldId: "inventorydetail",
line: i,
});
log.debug("value of i", i);
log.debug("hasSublistSubrec", hasSublistSubrec);
if (hasSublistSubrec) {
log.debug("inside If");
var InvDetailRecIR = currentRec.getSublistSubrecord({
sublistId: "item",
fieldId: "inventorydetail",
line:i
});
log.debug("InvDetailRecIR", InvDetailRecIR);
if (InvDetailRecIR) {
var InvDetailRec = objRecord.getSublistSubrecord({
sublistId: "inventory",
fieldId: "inventorydetail",
line: i,
});
if (InvDetailRec) {
try {
InvDetailRec.setSublistValue({
sublistId: "inventoryassignment",
fieldId: "receiptinventorynumber",
line: 0,
value:1786,
});
} catch (error) {
log.debug("error 228 receiptinventorynumber", error);
}
InvDetailRec.setSublistValue({
sublistId: "inventoryassignment",
fieldId: "issueinventorynumber", //"receiptinventorynumber",//
line: 0,
value: "12345",
});
InvDetailRec.setSublistValue({
sublistId: "inventoryassignment",
fieldId: "status",
line: 0,
value:1,
});
var binNum = InvDetailRecIR.getSublistValue({
sublistId: "inventoryassignment",
fieldId: "binnumber",
line: 0,
});
log.debug("binNum", binNum);
InvDetailRec.setSublistValue({
sublistId: "inventoryassignment",
fieldId: "binnumber",
line: 0,
value: binNum,
forceSyncSourcing: true,
});
log.debug("adjustQuanty223", adjustQuanty);
InvDetailRec.setSublistValue({
sublistId: "inventoryassignment",
fieldId: "quantity",
line: 0,
value: adjustQuanty,
});
}
} else {
log.debug("inside else 259");
// continue;
break;
}
} else {
log.debug("inside else 264");
// continue;
break;
}
}
var lotSet = InvDetailRec.getSublistValue({
sublistId: "inventoryassignment",
fieldId: "issueinventorynumber",
line: 0,
});
log.debug("lotSet 275", lotSet);
// log.debug(
// "lotSet 276",
// InvDetailRec.getSublistValue({
// sublistId: "inventoryassignment",
// fieldId: "receiptinventorynumber",
// line: 0,
// })
// );
log.debug("InvDetailRec 243 ",InvDetailRec)
var RecordCreated = objRecord.save();
log.debug("RecordCreated", RecordCreated);
if (RecordCreated) {
var output = url.resolveRecord({
recordType: "inventoryadjustment",
recordId: RecordCreated,
});
windows.open(output);
}
return true;
} catch (e) {
log.debug("Error in saveRecord", e);
}
}
return{
afterSubmit:afterSubmit
}
})
EAGLE
11/24/2022, 2:49 PMbattk
11/24/2022, 2:57 PMbattk
11/24/2022, 2:57 PMbattk
11/24/2022, 2:58 PMbattk
11/24/2022, 2:58 PMcurrentRec
, just harcode themEAGLE
11/24/2022, 2:59 PMEAGLE
11/24/2022, 3:04 PMtype: "error.SuiteScriptError",
name: "USER_ERROR",
message: "Items you have requested in the record have been deleted since you retrieved the form",
"battk
11/24/2022, 3:12 PMEAGLE
11/24/2022, 3:22 PM/**
*@NApiVersion 2.1
*@NScriptType userEventScript
*/
define(["N/record","N/url"], function (record,url){
function afterSubmit(context){
try {
log.debug("!--- Save Record Start--!");
var currentRec = context.newRecord;
var objRecord = record.create({
type: record.Type.INVENTORY_ADJUSTMENT,
});
var recordObject = {};
var client = currentRec.getValue({ fieldId: "entity" });
if (client) {
objRecord.setValue({ fieldId: "customer", value: client });
}
var date = currentRec.getValue({ fieldId: "trandate" });
if (date) {
objRecord.setValue({ fieldId: "trandate", value: new Date(date) });
}
var memo = currentRec.getValue({ fieldId: "memo" });
if (memo) {
objRecord.setValue({ fieldId: "memo", value: memo });
}
var department = currentRec.getValue({ fieldId: "department" });
if (department) {
objRecord.setValue({ fieldId: "department", value: department });
}
var location = currentRec.getValue({ fieldId: "location" });
if (location) {
objRecord.setValue({ fieldId: "adjlocation", value: location });
}
var adjustAccount = currentRec.getValue({
fieldId: "custbody_gbs_ir_adjust_acct",
});
if (adjustAccount) {
objRecord.setValue({ fieldId: "account", value: adjustAccount });
}
var sublistCount = currentRec.getLineCount({
sublistId: "item",
});
log.debug("sublistCount 111", sublistCount);
for (var i = 0; i < sublistCount; i++) {
var item = currentRec.getSublistValue({
sublistId: "item",
fieldId: "item",
line: i,
});
if (item) {
objRecord.setSublistValue({
sublistId: "inventory",
fieldId: "item",
value: item,
line: i,
forceSyncSourcing: true,
});
objRecord.setSublistValue({
sublistId: "inventory",
fieldId: "location",
value: location,
line: i,
forceSyncSourcing: true,
});
objRecord.setSublistValue({
sublistId: "inventory",
fieldId: "department",
value: department,
line: i,
});
}
var adjustQuanty = currentRec.getSublistValue({
sublistId: "item",
fieldId: "quantity",
line: i,
});
log.debug("adjustQuanty 146", adjustQuanty);
if (adjustQuanty) {
log.debug("adjustQuanty 147", adjustQuanty);
objRecord.setSublistValue({
sublistId: "inventory",
fieldId: "adjustqtyby",
value: adjustQuanty,
line: i,
forceSyncSourcing: true,
});
}
log.debug("item", item);
var units = currentRec.getSublistValue({
sublistId: "item",
fieldId: "units",
line: i,
});
if (units) {
objRecord.setSublistValue({
sublistId: "inventory",
fieldId: "units",
value: units,
line: i,
});
}
var memo = currentRec.getSublistValue({
sublistId: "item",
fieldId: "memo",
line: i,
});
if (memo) {
objRecord.setSublistValue({
sublistId: "inventory",
fieldId: "item",
value: memo,
line: i,
});
}
log.debug("memo", memo);
var hasSublistSubrec = currentRec.hasSublistSubrecord({
sublistId: "item",
fieldId: "inventorydetail",
line: i,
});
log.debug("value of i", i);
log.debug("hasSublistSubrec", hasSublistSubrec);
if (hasSublistSubrec) {
log.debug("inside If");
var InvDetailRecIR = currentRec.getSublistSubrecord({
sublistId: "item",
fieldId: "inventorydetail",
line:i
});
log.debug("InvDetailRecIR", InvDetailRecIR);
if (InvDetailRecIR) {
var InvDetailRec = objRecord.getSublistSubrecord({
sublistId: "inventory",
fieldId: "inventorydetail",
line: i,
});
if (InvDetailRec) {
// try {
// InvDetailRec.setSublistValue({
// sublistId: "inventoryassignment",
// fieldId: "receiptinventorynumber",
// line: 0,
// value:1786,
// });
// } catch (error) {
// log.debug("error 228 receiptinventorynumber", error);
// }
InvDetailRec.setSublistValue({
sublistId: "inventoryassignment",
fieldId: "issueinventorynumber", //"receiptinventorynumber",//
line: 0,
value: "12345",
});
InvDetailRec.setSublistValue({
sublistId: "inventoryassignment",
fieldId: "status",
line: 0,
value:1,
});
var binNum = InvDetailRecIR.getSublistValue({
sublistId: "inventoryassignment",
fieldId: "binnumber",
line: 0,
});
log.debug("binNum", binNum);
InvDetailRec.setSublistValue({
sublistId: "inventoryassignment",
fieldId: "binnumber",
line: 0,
value: 263,
forceSyncSourcing: true,
});
log.debug("adjustQuanty223", adjustQuanty);
InvDetailRec.setSublistValue({
sublistId: "inventoryassignment",
fieldId: "quantity",
line: 0,
value: 40,
});
}
} else {
log.debug("inside else 259");
// continue;
break;
}
} else {
log.debug("inside else 264");
// continue;
break;
}
}
var lotSet = InvDetailRec.getSublistValue({
sublistId: "inventoryassignment",
fieldId: "issueinventorynumber",
line: 0,
});
log.debug("lotSet 275", lotSet);
// log.debug(
// "lotSet 276",
// InvDetailRec.getSublistValue({
// sublistId: "inventoryassignment",
// fieldId: "receiptinventorynumber",
// line: 0,
// })
// );
log.debug("InvDetailRec 243 ",InvDetailRec)
var RecordCreated = objRecord.save();
log.debug("RecordCreated", RecordCreated);
if (RecordCreated) {
var output = url.resolveRecord({
recordType: "inventoryadjustment",
recordId: RecordCreated,
});
windows.open(output);
}
return true;
} catch (e) {
log.debug("Error in saveRecord", e);
}
}
return{
afterSubmit:afterSubmit
}
})
battk
11/24/2022, 3:28 PMfor (var i = 0; i < sublistCount; i++) {
battk
11/24/2022, 3:28 PMvar client = currentRec.getValue({ fieldId: "entity" });
battk
11/24/2022, 3:29 PMif (item) {
battk
11/24/2022, 3:29 PMbattk
11/24/2022, 3:29 PMbattk
11/24/2022, 3:30 PMobjRecord.setValue({ fieldId: "customer", value: client });
EAGLE
12/05/2022, 12:08 PMEAGLE
12/05/2022, 12:10 PMEAGLE
12/05/2022, 12:11 PMbattk
12/05/2022, 2:56 PMbattk
12/05/2022, 2:57 PMbattk
12/05/2022, 2:57 PMEAGLE
12/05/2022, 4:17 PMbattk
12/05/2022, 8:04 PMEAGLE
12/09/2022, 8:00 AMbattk
12/09/2022, 8:01 AMbattk
12/09/2022, 8:01 AMEAGLE
12/09/2022, 8:05 AM{
type: "inventorydetail",
isDynamic: false,
fields: {
nlloc: "0",
nlsub: "1",
ignoreqtyvalidation: "F",
trandate: "12/8/2022",
_eml_nkey_: "611679_SB1~7070~3~N",
type: "inventorydetail",
nsapiCT: "1670572708568",
sys_id: "-6993289412317604",
nluser: "7070",
nldept: "0",
tolocationusesbins: "F",
item: "3928",
quantity: "40.0",
sys_parentid: "-6993289357059503",
templatestored: "F",
entryformquerystring: "item=3928&unit=&quantity=40&trandate=12/8/2022&location=1&uitype=&subrecord_parent_tran_type=invadjst",
nlrole: "3",
_csrf: "rKmRBCOYOBccU_dWfOfVw6iceSV9oiTjPrWBcVC9Y_YNfQo7c339oggjikkhJ4sZIeUiisoF5WnelHFlOgGK1toSeqym7-HPO30471XYsu5JdQUb3e-5PPzTrcJ4naWHkN5QbsQcvLkXbRSEWbPyNuS7cAQCDTlaKblBCKp3chE=",
uitype: "MOH_STRICT_VALIDATION",
baserecordtype: "inventorydetail",
baseunitquantity: "40.0",
totalquantity: "0",
haslines: "F",
tolocation: "-1",
customform: "16",
location: "1"
},
sublists: {
inventoryassignment: {
currentline: {
basequantityavailable: "",
binnumber: "",
existingexpdate: "",
existinginventorynumber: "",
expirationdate: "",
internalid: "-1",
inventorydetail: "-1",
inventorystatus: "1",
issueinventorynumber: "",
issueinventorynumber_display: "",
lotquantityavailable: "",
numberedrecordid: "",
packcarton: "",
pickcarton: "",
quantity: "",
quantityavailable: "",
quantitystaged: "",
receiptinventorynumber: "",
sequencenumber: "",
sys_id: "-6993289414837270",
sys_parentid: "-6993289412317604",
tobinnumber: "",
tobinnumber_display: "",
toinventorystatus: "",
toinventorystatus_display: "",
totalquantityavailable: "",
"#": "1"
}
}
}
}
EAGLE
12/09/2022, 8:06 AMbattk
12/09/2022, 8:16 AMbattk
12/09/2022, 8:16 AMEAGLE
12/09/2022, 8:58 AMEAGLE
12/09/2022, 8:59 AMbattk
12/09/2022, 9:01 AMbattk
12/09/2022, 9:02 AMbattk
12/09/2022, 9:04 AMbattk
12/09/2022, 9:05 AMEAGLE
12/09/2022, 9:19 AMEAGLE
12/09/2022, 9:27 AM{
id: "3082",
type: "inventorydetail",
isDynamic: false,
fields: {
nlloc: "0",
nlsub: "1",
createdfrom: "-1",
ignoreqtyvalidation: "F",
trandate: "12/9/2022",
lineid: "1",
_eml_nkey_: "611679_SB1~7070~3~N",
type: "inventorydetail",
transactionid: "240101",
nsapiCT: "1670577998634",
sys_id: "6998579465277034",
nluser: "7070",
nldept: "0",
locationusesbins: "T",
id: "3082",
updatertype: "REGULAR",
tolocationusesbins: "F",
item: "3928",
quantity: "13",
sys_parentid: "6998579199463118",
templatestored: "F",
entryformquerystring: "item=3928&unit=103&quantity=13&e=T&trandate=12/9/2022&location=1&uitype=MOH_STRICT_VALIDATION&id=3082&subrecord_parent_tran_type=invadjst",
nlrole: "3",
_csrf: "rKmRBCOYOBccU_dWfOfVw6iceSV9oiTjPrWBcVC9Y_YNfQo7c339oggjikkhJ4sZIeUiisoF5WnelHFlOgGK1toSeqym7-HPO30471XYsu5JdQUb3e-5PPzTrcJ4naWHkN5QbsQcvLkXbRSEWbPyNuS7cAQCDTlaKblBCKp3chE=",
uitype: "MOH_STRICT_VALIDATION",
baserecordtype: "inventorydetail",
baseunitquantity: "13",
totalquantity: "13",
haslines: "T",
unit: "103",
tolocation: "-1",
customform: "16",
location: "1",
conversionrate: "1"
},
sublists: {
inventoryassignment: {
currentline: {
basequantityavailable: "",
binnumber: "",
existingexpdate: "",
existinginventorynumber: "",
expirationdate: "",
internalid: "-1",
inventorydetail: "-1",
inventorystatus: "1",
issueinventorynumber: "",
issueinventorynumber_display: "",
lotquantityavailable: "",
numberedrecordid: "",
packcarton: "",
pickcarton: "",
quantity: "",
quantityavailable: "",
quantitystaged: "",
receiptinventorynumber: "",
sequencenumber: "",
sys_id: "-6998579467820443",
sys_parentid: "6998579465277034",
tobinnumber: "",
tobinnumber_display: "",
toinventorystatus: "",
toinventorystatus_display: "",
totalquantityavailable: "",
"#": "2"
},
"line 1": {
basequantityavailable: null,
binnumber: "1",
binnumber_display: "DSP Cage Rack A",
existingexpdate: "11/1/2022",
existinginventorynumber: null,
expirationdate: "11/1/2022",
internalid: "3292",
inventorydetail:3082,
inventorystatus: "1",
inventorystatus_display: null,
issueinventorynumber: null,
issueinventorynumber_display: null,
lotquantityavailable: null,
numberedrecordid: "1786",
packcarton: null,
pickcarton: null,
quantity: "13",
quantityavailable: null,
quantitystaged: null,
receiptinventorynumber: "12345",
sequencenumber: "1",
sys_id: "6998579459938863",
sys_parentid: "6998579465277034",
tobinnumber: null,
tobinnumber_display: null,
toinventorystatus: null,
toinventorystatus_display: null,
totalquantityavailable: null
}
}
}
}
battk
12/09/2022, 9:30 AMbattk
12/09/2022, 9:32 AMEAGLE
12/09/2022, 9:33 AMEAGLE
12/09/2022, 9:36 AMEAGLE
12/09/2022, 12:11 PM