-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem_order_lookup_client.ts
46 lines (41 loc) · 1.13 KB
/
item_order_lookup_client.ts
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
42
43
44
45
46
/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
import { EntryPoints } from 'N/types';
import * as record from 'N/record';
/**
* A client script to lookup customer record.
*/
export const pageInit: EntryPoints.Client.pageInit = (
context: EntryPoints.Client.pageInitContext
) => {
console.log('Item Order Client Script Loaded...');
};
export const fieldChanged: EntryPoints.Client.fieldChanged = (
context: EntryPoints.Client.fieldChangedContext
) => {
const currentRecord = context.currentRecord;
const fieldName = context.fieldId;
const value = currentRecord.getValue(fieldName);
console.log('Changed Field: ' + fieldName);
if (fieldName === 'custpage_customer' && value !== '') {
// check if is valid internal id
if (isNaN(Number(value))) {
alert(value + 'is not a valid internal id.');
} else {
try {
const customer = record.load({
type: 'customer',
id: value,
});
alert(
'You have entered the internal id for customer: ' +
customer.getValue('entityid')
);
} catch (e) {
alert(e.message);
}
}
}
};