我正在尝试加载通过SuiteScript 2.0从事务发送的所有电子邮件。
当我跑步时
record.getSublists()
它返回以下内容:
["item","activeworkflows","workflowhistory","custom8","messages","contacts","activities","usernotes","systemnotes","mediaitem","links","cases","partners","events","calls","tasks"]
然而,当我尝试运行以下内容时:
record.getSublist('messages');
我收到错误。
我需要能够查看上次发送的电子邮件的日期,以便我可以确定是否发送后续电子邮件。
答案 0 :(得分:1)
我通常采用的方法是使用Search API来获取此类信息:
require(['N/search'], function(search) {
var result = search.create({
type: 'transaction',
filters: [
['internalid', search.Operator.ANYOF, id], 'AND',
['mainline', search.Operator.IS, 'T'], 'AND',
['messages.messagetype', search.Operator.ANYOF, 'EMAIL'], 'AND',
['messages.isincoming', search.Operator.IS, 'F']
],
columns: [
search.createColumn({name: 'internalid', summary: search.Summary.GROUP}),
search.createColumn({name: 'messagedate', join: 'messages', summary: search.Summary.MAX}),
],
}).run().getRange({ start: 0, end: 1 });
var dateOfLastEmail = result[0].getValue({ name: 'messagedate', join: 'messages', summary: search.Summary.MAX });
});