[英]Javascript attachment via email
我需要JavaScript函數方面的幫助。 我正在使用ServiceNow平台。
我有要求:
我正在使用“ 精英”頁面上發布的代碼。
問題:
為什么將附件兩次添加到記錄中? 如何僅通過電子郵件客戶端獲取最新更新中添加的附件?
//Table: Email [sys_email]
//When: after
//Insert: true
//Update: true
//Condition: !current.instance.nil() && current.type == 'received'
//Script:
addAttachmentAudit();
function addAttachmentAudit() {
var instance = current.instance;
var targetTable = current.target_table;
var grAttachment = new GlideRecord('sys_attachment');
grAttachment.addQuery('table_sys_id',current.sys_id);
grAttachment.query();
while(grAttachment.next()){
grAttachment.table_name = targetTable;
grAttachment.table_sys_id = instance;
grAttachment.update();
var grTargetTable = new GlideRecord(targetTable);
grTargetTable.addQuery('sys_id',instance);
grTargetTable.query();
while (grTargetTable.next()) {
grTargetTable.work_notes =
"Attachment added: " + grAttachment.file_name +
" by email from " + current.sys_created_by;
grTargetTable.update();
}
}
}
您是否考慮過消除while(grTargetTable.next())塊? 只需一次手動對grTargetTable.next()進行操作,因為您是通過sys_id查詢的,因此應該只有一個。
我想知道是否有任何效果。 抱歉,我無法直接評論您的問題,我的代表還不夠。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.