Load Email messages attached to transaction Suitescript 2.0

帅比萌擦擦* 提交于 2020-01-07 02:34:26

问题


I'm trying to load up all of the emails that have been sent from a transaction via SuiteScript 2.0.

When I run

record.getSublists()

it returns the following:

["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 receive an error.

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.


回答1:


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 });
});


来源:https://stackoverflow.com/questions/42770084/load-email-messages-attached-to-transaction-suitescript-2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!