forked from headintheclouddev/typings-suitescript-2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-ClientScript.ts
38 lines (34 loc) · 975 Bytes
/
example-ClientScript.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
/**
* @NAPIVersion 2.0
* @NScriptType ClientScript
*/
import {EntryPoints} from 'N/types'
import * as search from 'N/search'
export function pageInit(ctx: EntryPoints.Client.pageInitContext) {
if (ctx.mode != 'edit') return;
search.create.promise({
type: 'customer',
filters: [
search.createFilter({
name: 'companyname',
operator: search.Operator.ISNOTEMPTY
}),
],
columns: [
search.createColumn({
name: 'companyname',
sort: search.Sort.ASC
}),
{ name: 'email', },
'fax',
],
}).then(search => {
return search.run().getRange.promise({
start: 0,
end: 1
});
}).then(results => {
if (results.length === 0) return alert("No companies");
alert(`First company alphabetically: ${results[0].getValue('companyname')}`);
});
}