SuiteScript 2.0 - 如何从 UserEventType 获取字符串

SuiteScript 2.0 - How to get string from UserEventType

以下代码创建一个包含详细信息的日志条目:UserEventType:[object Object],内部 ID:11。

define(['N/log'], function (log)
{    
    function afterSubmit(context)
    {
        log.debug({
            title: 'afterSubmit',
            details: 'UserEventType: ' + context.UserEventType + ', Internal id: ' + context.newRecord.id
        });
    }
});

如何从 context.UserEventType 中获取有意义的字符串?

context.UserEventType 是一个对象。

因此,要获得完整的日志详细信息,您可以使用

log.debug({
  title: 'afterSubmit',
  details: 'UserEventType: ' + JSON.stringify(context.UserEventType) + ', Internal id: ' + context.newRecord.id
});

log.debug({
  title: 'afterSubmit',
  details: {
    'UserEventType': context.UserEventType,
    'Internal id': context.newRecord.id
  }
});