添付ファイルの情報オブジェクトの配列を返す

  function getAttachFileItems(xsp_doc, field_name) {
    var items:java.util.List = xsp_doc.getAttachmentList(field_name);
    var back_doc:NotesDocument = xsp_doc.getDocument();
    var unid = back_doc.getUniversalID();
    var parentDB:NotesDatabase = back_doc.getParentDatabase();
    var path = parentDB.getFilePath();
    var fileItems = [];
    for(var index=0; index<items.length; index++) {
      var attach_obj = items.get(index);
      var file_item = {}
      file_item.name = attach_obj.getName();
      file_item.url = "../" + path + "/0/" + unid + "/$FILE/" + file_item.name;
      fileItems.push(file_item);
    }
    return fileItems;
  }

// 使い方. <xp:repeat>と組み合わせて使ったりする
var fileInfos = getAttachFileItems(xsp_doc, "ファイル用フィールド");
for(var index=0; index < fileInfos.length; index++) {
  var fileInfo = fileInfos[index];
  // fileInfo.urlは相対URL、fileInfo.nameはファイル名を返す
}




JavaScript (Server)
yac4423
December 10, 2015 1:11 AM
Rating
0





No comments yetLogin first to comment...