“.replace” with XML file

Steps to create XML file using “.replace”

  1. Download the sample of the XML file you want and add it to the file cabinet
  2. This is a sample image for XML tag in the sample file

3. We can replace invoiceData here by using .replace

In SuiteScript, you can use the N/file module to read and write files, including XML files. To replace text in an XML file, you can use a combination of the N/file module

let fileObj = file.load({id: fileId});
let Template = fileObj.getContents().replace("<!--invoiceDate-->", new Date().toISOString().slice(0,10))
 

Leave a comment

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