Transaction Logs as attachments in NetSuite Custom transactions

We’ve added functionality in NetSuite to store transaction logs received from the Portal via an API POST request using a RESTlet script. Two folders have been created in the file cabinet ‘Pending Donation’ and ‘Outgoing Fund’ to store the files. The files are saved in the format ‘<record type>_<internal id>. <file type>’ (e.g., pend_donation_102.png). We tested this with sample base64 data, and it’s correctly storing files in the respective folders. The functionality works fine with PNG, JPEG, and PDF formats. 

 

An API that will take the following values as API parameters:  

  • Record type: Pending Donation or Outgoing Fund.  
  • Internal ID of the record (Pending Donation or Outgoing Fund).  
  • The snapshot(image/PDF) of the completed transaction in base64 text format.  
  • File type: The mime type of the snapshot file (“image/png”, “image/jpeg”, or “application/pdf”) The base64 text will be converted to an image/PDF and will be stored in the NetSuite file cabinet. This file will be attached to the record specified in the request (Pending Donation or Outgoing Fund). 

Notes: 

  • The NetSuite API has a file size limit of 10 MB. The ‘base64’ encoding of a file can be approximately 33% larger than the original file size. If the file is larger than 7.5 MB, the ‘base64’ text might exceed 10 MB limit. If the request exceeds the limit, the request will return an error.  
  • NetSuite has a concurrency limit based on the Suite Cloud processors.  
  • If an API request fails, it should be handled by the portal by resending the failed requests again.  
  • If the data is not correctly passed in the specified format, the API will return an error. 

Testing steps 

In Postman, add the record type, internal ID, and File Content fields to the body. Then, send the request and verify that you receive the file ID in the response. After that, check the respective folders. The created file will be stored in the appropriate folder corresponding to the record type. Below, I’ve provided sample data for you to test with 

    “recordType”: “”

    “internalId”: “”

    “fileContent”:”base64” “data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3/OAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANCSURBVEiJtZZPbBtFFMZ/M7ubXdtdb1xSFyeilBapySVU8h8OoFaooFSqiihIVIpQBKci6KEg9Q6H9kovIHoCIVQJJCKE1ENFjnAgcaSGC6rEnxBwA04Tx43t2FnvDAfjkNibxgHxnWb2e/u992bee7tCa00YFsffekFY+nUzFtjW0LrvjRXrCDIAaPLlW0nHL0SsZtVoaF98mLrx3pdhOqLtYPHChahZcYYO7KvPFxvRl5XPp1sN3adWiD1ZAqD6XYK1b/dvE5IWryTt2udLFedwc1+9kLp+vbbpoDh+6TklxBeAi9TL0taeWpdmZzQDry0AcO+jQ12RyohqqoYoo8RDwJrU+qXkjWtfi8Xxt58BdQuwQs9qC/afLwCw8tnQbqYAPsgxE1S6F3EAIXux2oQFKm0ihMsOF71dHYx+f3NND68ghCu1YIoePPQN1pGRABkJ6Bus96CutRZMydTl+TvuiRW1m3n0eDl0vRPcEysqdXn+jsQPsrHMquGeXEaY4Yk4wxWcY5V/9scqOMOVUFthatyTy8QyqwZ+kDURKoMWxNKr2EeqVKcTNOajqKoBgOE28U4tdQl5p5bwCw7BWquaZSzAPlwjlithJtp3pTImSqQRrb2Z8PHGigD4RZuNX6JYj6wj7O4TFLbCO/Mn/m8R+h6rYSUb3ekokRY6f/YukArN979jcW+V/S8g0eT/N3VN3kTqWbQ428m9/8k0P/1aIhF36PccEl6EhOcAUCrXKZXXWS3XKd2vc/TRBG9O5ELC17MmWubD2nKhUKZa26Ba2+D3P+4/MNCFwg59oWVeYhkzgN/JDR8deKBoD7Y+ljEjGZ0sosXVTvbc6RHirr2reNy1OXd6pJsQ+gqjk8VWFYmHrwBzW/n+uMPFiRwHB2I7ih8ciHFxIkd/3Omk5tCDV1t+2nNu5sxxpDFNx+huNhVT3/zMDz8usXC3ddaHBj1GHj/As08fwTS7Kt1HBTmyN29vdwAw+/wbwLVOJ3uAD1wi/dUH7Qei66PfyuRj4Ik9is+hglfbkbfR3cnZm7chlUWLdwmprtCohX4HUtlOcQjLYCu+fzGJH2QRKvP3UNz8bWk1qMxjGTOMThZ3kvgLI5AzFfo379UAAAAASUVORK5CYII=”

 

Leave a comment

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