-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem_report_record_client.ts
41 lines (36 loc) · 1.1 KB
/
item_report_record_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
/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
import { EntryPoints } from 'N/types';
import * as runtime from 'N/runtime';
/**
* A client script to generate a link to the item report suitelet.
*/
export const pageInit: EntryPoints.Client.pageInit = () => {
console.log('Item Report CR Client Script Loaded');
};
export const fieldChanged = (
context: EntryPoints.Client.fieldChangedContext
) => {
const suiteletLink = runtime.getCurrentScript().getParameter({
name: 'custscript_sp_item_w_rg_suitelet_link',
}) as string;
const record = context.currentRecord;
if (context.fieldId === 'custrecord_sp_item_report_rep_group') {
const reportingGroupValue = record.getValue(
'custrecord_sp_item_report_rep_group'
) as string;
const reportingGroupText = record.getText(
'custrecord_sp_item_report_rep_group'
) as string;
// build the link
const link = `${suiteletLink}&group=${reportingGroupValue}&name=${encodeURIComponent(
reportingGroupText
)}`;
record.setValue({
fieldId: 'custrecord_sp_item_report_items',
value: link,
});
}
};