SCL-303 Tax Exemption Certificate
This extension has JS, Template, SCSS, SuiteScript files. We have to provide permission for the SS file manually. The extension will be helpful for the user to remove tax from their order if they have a tax free certificate, below are the steps to create the extension
- Create 2 custom transaction body fields checkbox and document field, make sure you check the webstore checkbox in the apply section
- Add the field ID to configuration record in SO custom field section
- Now we have to add the fields in SCA website, I have added it under the place order button, use the below format to do it

<div class="order-wizard-shipmethod-module-deliverynote" style="display: none;">
<label for="custbody_tax_free_order">
{{model.__customFieldsMetadata.custbody_tax_free_order.label}}?
</label>
<input type="checkbox" name="custbody_tax_free_order" style="vertical-align: -webkit-baseline-middle; margin-left: 5px;">
</div>
<div class="order-wizard-shipmethod-module-deliverynote" style="display: none;">
<label for="custbody_tax_free_certificate">
{{model.__customFieldsMetadata.custbody_tax_free_certificate.label}}?
</label>
<input type="text" name="custbody_tax_free_certificate" style="vertical-align: -webkit-baseline-middle; margin-left: 5px;">
</div>
Note that we cannot add a document directly to the document field that we have created. So we need to create an extension to accept the file, upload then get internal id of the file. This internal id is filled to the document field created.
//ENTRY POINT
layout.addChildView('Upload.Certificate', function() {
return new UploadFileView({ container: container });
});


// SCG.TaxFreeOrders.SCGTaxFreeExt.js
// Load all your starter dependencies in backend for your extension here
// ----------------
define('SCG.TaxFreeOrders.SCGTaxFreeExt', [
'SCG.TaxFreeOrders.SCGTaxFreeExt.ServiceController', 'SC.Model'
], function(
SCGTaxFreeExtServiceController, SCModel
) {
'use strict';
return SCModel.extend({
name: 'SCGTaxFreeOrdersSCGTaxFreeExt'
,
uploadAction: function(FILENAME, EXTENSION, FILE) {
var FOLDERID = 625740; //Webstore tax Free Certificates in filecabinet
var fileUploaded = false;
console.log('FILENAME', FILENAME)
if (EXTENSION == "pdf") {
var newFile = nlapiCreateFile(FILENAME, 'PDF', FILE);
fileUploaded = true;
} else if (EXTENSION == "doc") {
var newFile = nlapiCreateFile(FILENAME, 'WORD', FILE);
fileUploaded = true;
} else if (EXTENSION == "docx") {
var newFile = nlapiCreateFile(FILENAME, 'WORD', FILE);
fileUploaded = true;
}
if (fileUploaded) {
newFile.setFolder(FOLDERID);
var newFileId = nlapiSubmitFile(newFile);
console.log('newFileId', newFileId)
return JSON.stringify({ success: true, fileId: newFileId });
} else {
return JSON.stringify({ success: false, message: "You're trying to upload a file that is not acceptable" });
}
}
});
});