-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvendor_bills_client.ts
70 lines (62 loc) · 1.96 KB
/
vendor_bills_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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
import { EntryPoints } from 'N/types';
import * as currentRecord from 'N/currentRecord';
/**
* A client script to handle user events for the vendor bills suitelet.
*/
export const pageInit: EntryPoints.Client.pageInit = () => {
console.log('Vendor Bills Client Loaded...');
};
export const sublistChanged: EntryPoints.Client.sublistChanged = (
context: EntryPoints.Client.sublistChangedContext
) => {
// var currentRecord = context.currentRecord;
const sublistName = context.sublistId;
console.log('changed sublist: ' + sublistName);
};
export const saveRecord: EntryPoints.Client.saveRecord = () => {
const cr = currentRecord.get();
const lines = cr.getLineCount({ sublistId: 'custpage_transactions_sublist' });
let transactions = [];
for (let i = 0; i < lines; i++) {
const cb = cr.getSublistValue({
sublistId: 'custpage_transactions_sublist',
fieldId: 'custpage_result_checkbox',
line: i,
});
const transactionId = cr.getSublistValue({
sublistId: 'custpage_transactions_sublist',
fieldId: 'custpage_result_id',
line: i,
});
const transactionNumber = cr.getSublistValue({
sublistId: 'custpage_transactions_sublist',
fieldId: 'custpage_result_number',
line: i,
});
const vendorId = cr.getSublistValue({
sublistId: 'custpage_transactions_sublist',
fieldId: 'custpage_result_vendor_id',
line: i,
});
const amount = cr.getSublistValue({
sublistId: 'custpage_transactions_sublist',
fieldId: 'custpage_result_amount',
line: i,
});
if (cb) {
transactions.push({
transactionId: transactionId,
transactionNumber: transactionNumber,
vendorId: vendorId,
amount: amount,
});
}
}
console.log('Setting custpage_transactions: ' + JSON.stringify(transactions));
cr.setValue('custpage_transactions', JSON.stringify(transactions));
return true;
};