获取时间表时出现问题。提交前摊销日记帐分录用户事件的行级字段

问题描述 投票:0回答:1

我已创建摊销计划日记账分录。需要获取时间表编号。行级字段。我在提交脚本之前创建了用户事件。我能够获取部门、描述、时间表编号。编辑模式下的字段值。创建模式下的部门和描述。但在附表编号中获得空白值。字段日志即使在创建模式下也有价值。如何获取这个值?

/**

  • @NApi版本2.x
  • @NScriptType 用户事件脚本 */

define(['N/记录', 'N/ui/serverWidget', 'N/搜索', 'N/ui/消息', 'N/运行时'],

function (record, serverWidget, search, message, runtime) {

    function beforeSubmit(context) {
        // try {
                               
                var rec = context.newRecord;
                 
                
                var recType = rec.type;
                log.debug("recType",recType);
                

               //Journal Entry
                if (recType === 'journalentry') {
                    log.debug("context",context.type);
                      if (context.type === 'create') {
                    log.debug("creating......");
                    
                                                      
                    var numLines = rec.getLineCount({
                        sublistId: 'line'
                    });
                    log.debug("numLines", numLines);
                   
                    
                    for(var s=0;s<numLines;s++)
                    {
                          
                         var scheduleNo = rec.getSublistValue({
                            sublistId: 'line',
                            fieldId: 'schedulenum',
                            line: s
                        });
                        log.debug("scheduleNo", scheduleNo);

                        var department = rec.getSublistValue({
                            sublistId: 'line',
                            fieldId: 'department',
                            line: s
                        });
                        log.debug("department", department);

                        var decs = rec.getSublistValue({
                            sublistId: 'line',
                            fieldId: 'memo',
                            line: s
                        });
                        log.debug("decs", decs);

               
                }

            
                }

               
            } 
    
    }

    return {
        beforeSubmit: beforeSubmit
    }

});
netsuite suitescript suitescript2.0
1个回答
0
投票

我可以使用下面的代码在创建模式下获取 Schedule num 的值

/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 */
define(['N/record', 'N/log'], function(record, log) {
      const beforeSubmit = (context) => {
        try {
          // Ensure the script runs only on create
          if (context.type !== context.UserEventType.CREATE) {
            return;
          }
          const { newRecord } = context;
    
          // Get the number of lines
          let lineCount = newRecord.getLineCount({ sublistId: 'line' });
    
    for (let i = 0; i < lineCount; i++) {
    const scheduleNo= newRecord.getSublistValue({
              sublistId: 'line',
              fieldId: 'schedulenum',
              line: i
            });
    log.debug('schedule num', scheduleNo);
    }
        } catch (e) {
          log.error({
            title: e.name,
            details: e.message
          });
        }
      };
    
      return {
        beforeSubmit: beforeSubmit
      };
    });
© www.soinside.com 2019 - 2024. All rights reserved.