-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexposeItemTemplate.ts
33 lines (30 loc) · 1.31 KB
/
exposeItemTemplate.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
///<reference path='c:\development\Netsuite\SuiteScriptAPITS.d.ts'/>
module kotnShadowItemTemplate{
/**
* copy store template item to field available in searches
* @param {string} type event type
* @return {void}
*/
export function itemBeforeSubmit(type) {
if (type == 'edit' || type == 'create') {
var tmplt = nlapiGetFieldText('storeitemtemplate');
var shadow = nlapiGetFieldValue('custitem_kotn_shadow_template');
if (tmplt != shadow) nlapiSetFieldValue('custitem_kotn_shadow_template', tmplt);
}
}
/**
* expose the item template after bundle install. You'll need a deployment
* for each type of item. e.g., Inventory Item, Non-Inventory Item, Serialized Item
* @param {string} recType Record type supplied by the mass update runner
* @param {string|number} recId Item internal id supplied by the mass update runner
*/
export function massShadow(recType, recId) {
var item = nlapiLoadRecord(recType, recId);
var tmplt = item.getFieldText('storeitemtemplate') || '';
var shadow = item.getFieldValue('custitem_kotn_shadow_template') || '';
if (tmplt != shadow) {
item.setFieldValue('custitem_kotn_shadow_template', tmplt);
nlapiSubmitRecord(item, {disabletriggers:true,ignoremandatoryfields:true, enablesourcing:false});
}
}
}