Advertisement
Guest User

Answer to Yamini Surender's Question

a guest
Feb 17th, 2017
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //########## CLIENTSCRIPT ##########
  2. var SEARCHMODULE, RECORDMODULE;
  3. define(['N/search', 'N/record'], runClientscript);
  4.        
  5. function runClientscript(search, record){
  6.     SEARCHMODULE = search;
  7.     RECORDMODULE = record;
  8.    
  9.     //*********** HELPER FUNCTIONS ***********
  10.     function create_amort_schedule(recordid) {//Here you receive the record id. Alternatively you can use SS 1.0 nlapiGetRecordId() but its deprecated.
  11.         var YOUR_RECORD_TYPE = 'custrecord_XXXX';
  12.         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
  13.         var v_loan_pymt_mthd = fieldLookUp.custrecordpfg_adv_loan_pymt_type;
  14.         alert(v_loan_pymt_mthd);
  15.         return;
  16.     }
  17.    
  18.     var returnObj = {};
  19.     returnObj.create_amort_schedule = create_amort_schedule;
  20.     return returnObj;
  21. }
  22.  
  23. //########## USEREVENT ##########
  24. var WIDGETMODULE;
  25. /**
  26.  *@NApiVersion 2.x
  27.  *@NModuleScope Public
  28.  *@NScriptType UserEventScript
  29.  */
  30. define(['N/ui/serverWidget'], runUserEvent);
  31.  
  32. function runUserEvent(widget) {
  33.     WIDGETMODULE = widget;
  34.  
  35.     var returnObj = {};
  36.     returnObj.beforeLoad = beforeLoad;
  37.     return returnObj;
  38. }
  39.  
  40. function beforeLoad(context) {  
  41.     if (context.type == context.UserEventType.VIEW) {
  42.       context.form.clientScriptFileId = 13553;
  43.       context.form.addButton({
  44.         id : 'custpage_some_button',
  45.         label : 'Schedule',
  46.         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.
  47.       });
  48.     }
  49.     return;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement