加载附加到事务Suitescript 2.0的电子邮件 [英] Load Email messages attached to transaction Suitescript 2.0
本文介绍了加载附加到事务Suitescript 2.0的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试加载通过SuiteScript 2.0从事务发送的所有电子邮件.
I'm trying to load up all of the emails that have been sent from a transaction via SuiteScript 2.0.
我跑步时
record.getSublists()
它返回以下内容:
["item","activeworkflows","workflowhistory","custom8","messages","contacts","activities","usernotes","systemnotes","mediaitem","links","cases","partners","events","calls","tasks"]
但是,当我随后尝试运行以下命令时:
However, when I then try to run the following:
record.getSublist('messages');
我收到一个错误.
我需要能够检查最近发送的电子邮件的日期,以便确定是否发送后续电子邮件.
I need to be able to check the date of the last email sent so I can determine whether or not to send a follow-up email.
推荐答案
我通常采用的方法是使用Search API获取此类信息:
The approach I typically take is to use the Search API to get this type of information:
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 });
});
这篇关于加载附加到事务Suitescript 2.0的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文