-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_lot_code_cs.js
41 lines (41 loc) · 1.38 KB
/
set_lot_code_cs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
define(['N/log'], function(log) {
function pageInit(context) {
if (context.mode !== 'create') //only execute in create mode
return;
var currentRecord = context.currentRecord;
var itemName = currentRecord.getText({
fieldId: "item"
});
if(itemName.search(/SPFG/i) != -1 || itemName.search(/SPWIP/i) != -1){
var currentDate = new Date();
var date = currentDate.getFullYear().toString();
var month = currentDate.getMonth() + 1;
if(month < 10){
month = "0" + month.toString();
}
date += (month).toString();
var day = currentDate.getDate();
if(day < 10){
day = "0" + day.toString();
}
date += day.toString();
currentRecord.selectLine({
sublistId: 'inventoryassignment',
line: 0
});
currentRecord.setCurrentSublistText({ //set date as lot number on new inventory details
sublistId: 'inventoryassignment',
fieldId: 'receiptinventorynumber',
text: date,
ignoreFieldChange: true
});
}
}
return {
pageInit: pageInit
}
});