Get the image URL from the NetSuite

If we know the internal id of the image file, we can fetch the image URL using a document saved search from the image file in the file cabinet instead of fetching the image from the item record.

var itemID
var fileSearchObj = search.create({
   type: "file",
   filters:
   [
      ["internalid","anyof", itemID]
   ],
   columns:
   [
      search.createColumn({
         name: "name",
         sort: search.Sort.ASC,
         label: "Name"
      }),
      search.createColumn({name: "folder", label: "Folder"}),
      search.createColumn({name: "documentsize", label: "Size (KB)"}),
      search.createColumn({name: "url", label: "URL"}),
      search.createColumn({name: "created", label: "Date Created"}),
      search.createColumn({name: "modified", label: "Last Modified"}),
      search.createColumn({name: "filetype", label: "Type"})
   ]
});
var searchResultCount = fileSearchObj.runPaged().count;
log.debug("fileSearchObj result count",searchResultCount);
fileSearchObj.run().each(function(result){
   // .run().each has a limit of 4,000 results
   return true;
});

Leave a comment

Your email address will not be published. Required fields are marked *