Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //########## CLIENTSCRIPT ##########
- var SEARCHMODULE, RECORDMODULE;
- define(['N/search', 'N/record'], runClientscript);
- function runClientscript(search, record){
- SEARCHMODULE = search;
- RECORDMODULE = record;
- //*********** HELPER FUNCTIONS ***********
- function create_amort_schedule(recordid) {//Here you receive the record id. Alternatively you can use SS 1.0 nlapiGetRecordId() but its deprecated.
- var YOUR_RECORD_TYPE = 'custrecord_XXXX';
- var fieldLookUp = SEARCHMODULE.lookupFields({ type: YOUR_RECORD_TYPE, id: recordid, columns: ['custrecordpfg_adv_loan_pymt_type']});//Doing a lookup cause its faster than loading the record
- var v_loan_pymt_mthd = fieldLookUp.custrecordpfg_adv_loan_pymt_type;
- alert(v_loan_pymt_mthd);
- return;
- }
- var returnObj = {};
- returnObj.create_amort_schedule = create_amort_schedule;
- return returnObj;
- }
- //########## USEREVENT ##########
- var WIDGETMODULE;
- /**
- *@NApiVersion 2.x
- *@NModuleScope Public
- *@NScriptType UserEventScript
- */
- define(['N/ui/serverWidget'], runUserEvent);
- function runUserEvent(widget) {
- WIDGETMODULE = widget;
- var returnObj = {};
- returnObj.beforeLoad = beforeLoad;
- return returnObj;
- }
- function beforeLoad(context) {
- if (context.type == context.UserEventType.VIEW) {
- context.form.clientScriptFileId = 13553;
- context.form.addButton({
- id : 'custpage_some_button',
- label : 'Schedule',
- functionName : 'create_amort_schedule(' + context.newRecord.id + ')' //Notice how you need to pass the id of the record as an argument. Your clientscript will receive it.
- });
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement