简体   繁体   中英

Netsuite: How to debug workflow action script

I'm new on suitescript(Javascript based used in Netsuite custumization). I have a workflow action script and want to debug it via Scritp Debugger in Netsuite.But I couldnt see my workflow action script in Debugger, even if I invoked the custom action.

I use Eclipse IDE and upload my file to Netsuite. Here is my code, simply it just adds expense report info note to employee when the empolyee expense report is created. It has a problem with returning type.

function UpdateEmployeeWithExpenseReport()
{
   var stFrequentCriteria = nlapiGetContext().getSetting('SCRIPT',
        'custscript_oradata_freq_trav_limit');  // get value of the script parameter
   var intFrequentCriteria = parseInt(stFrequentCriteria); //the limit of frequency
   var recExpenseReport = nlapiGetNewRecord();
   var stEntity = recExpenseReport.getFieldValue('entity');  
   var today = new Date();
   var aMonthAgo = nlapiAddDays(today, -30); 
   // filter just the main lines of expenses
   var arrSearchFilters =  [
        new nlobjSearchFilter('employee', null, 'is', stEntity),
        new nlobjSearchFilter('trandate', null, 'within', aMonthAgo, today),
        new nlobjSearchFilter('mainline', null, 'is', 'T') ];                                                   
   var arrSearchColumns = [ new nlobjSearchColumn('internalid', null, 'count') ]; // Note: count is not a field, it just counts internal id based on  Empolyee expenses reports
   var arrSearchResults = nlapiSearchRecord('expensereport', null,
        arrSearchFilters, arrSearchColumns);
   var stCount = arrSearchResults[0].getValue(arrSearchColumns[0]); //                                                                  
   var count = parseInt(stCount);
   var stFrequentTraveler = '';
   if (count >= intFrequentCriteria)
   {
      stFrequentTraveler = 'Frequent';
   }
   else 
   {
    stFrequentTraveler = 'Infrequent';
   }

   var stAmount = recExpenseReport.getFieldValue('amount');
   var intExpenseLines = recExpenseReport.getLineItemCount('expense');
   var stNotes = '';
   stNotes += stFrequentTraveler + 'Traveler' + '\n';
   stNotes += 'Last Expense Report' + '\n';
   stNotes += '--Expense Report Total= ' + stAmount + '\n';
   stNotes += '--Expense Lines = ' + intExpenseLines;

   var recEmployee = nlapiLoadRecord('employee', stEntity); // 1 internal name of record, 2.internal id for the  record

   recEmployee.setFieldValue('comments', stNotes);
   nlapiLogExecution('tDEBUG', 'stEntity', stEntity);
   stEntity = recEmployee.getFieldValue('entityid');

为了使您的脚本显示在Netsuite脚本调试器中,您需要在脚本部署记录上将“状态”设置为“正在测试”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM