Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NetSuite_SuiteScript_2.0_Custom_Module
/**
* CB_CM_CustomModule.js
* @NApiVersion 2.x
* @NModuleScope SameAccount
*
* @Author: Charles.Bastian
* @Created: 2020-03-12
* @ScriptName: CB_CM_CustomModule
* @Filename: CB_CM_CustomModule.js
* @ScriptID:
*
* @Usage: Define: define(['../O2_customModules/CB_CM_CustomModule'],function(CB_CM_CustomModule){
* Setter: rec=CB_CM_CustomModule.setter(rec,'fieldID','newFieldValue',true/false - ignore field change);
* Getter: response=CB_CM_CustomModule.getter(rec,fieldID);
* @Description: Custom module script for library functions.
* @modifications:
* Version Date Author Remarks
* v1.3.12-1 2020-03-12 Charles.Bastian Created with getter and setter functions.
* v1.3.12-2 2020-03-12 Charles.Bastian Promoted to production
*
*/
define(['N/record'],function(record){
function setFieldValue(rec,fieldID,fieldValue,ignoreChange){
if((rec!==undefined && fieldID!==undefined && fieldValue!==undefined) && (rec!='' && fieldID!='' && fieldValue!='')){
if(ignoreChange=='' || ignoreChange==null){ignoreChange=true;}
try{
rec.setValue({
fieldId:fieldID,
value:fieldValue,
ignoreFieldChange:ignoreChange
});
}catch(err01){
log.error('Error err01',JSON.strinigfy(err01));
return rec;
}
}
return rec;
}
function getFieldValue(rec,fieldID){
var fieldValue='';
try{
if((rec!==undefined && fieldID!==undefined) && (rec!='' && fieldID!='')){
fieldValue=rec.getValue({
fieldId:fieldID
});
}
}catch(err02){
log.error('Error err02',JSON.strinigfy(err02));
return fieldValue;
}
return fieldValue;
}
return{
setter:setFieldValue,
getter:getFieldValue
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment