Jira Code: TC-26
This topic includes all the workflow script done for sending email to customer by a button click. The workflow run on Credit memo, invoice, Sales order, estimate, customer statement.
/**
* Script Description
* To create email with Statement attachment PDF send to seconadry email
*
* Created on 17-Sep-2018
*/
/*******************************************************************************
* * Taipan Canada | TC-26 *
* **************************************************************************
*
*
* Author: Jobin & Jismi IT Services LLP
*
* REVISION HISTORY
*
*Ravin
*
******************************************************************************/
/**
* SCRIPT ID : { Name : TC-26 JJ-Oneweld SO Send Email On create , ID : }
*
* DEPLOYMENT : { Title :TC-26 JJ-Oneweld SO Send Email On create, ID : }
*
*
*/
function SendEmail() {
try {
var id = nlapiGetRecordId();
var customer = nlapiGetFieldValue('entity');
var email = nlapiGetFieldValue('email'); //internal id of the custom field
var SOid = nlapiGetFieldValue('tranid');
var records = new Object();
records['entity'] = customer;
records['transaction'] = id;
var file = nlapiPrintRecord('TRANSACTION', id, 'PDF', { 'formnumber': '100' });
var subject = "Sales Order #" + SOid;
var body = "Hello,<br \/>";
body += "<br \/>";
body += "Thank you for your business!<br \/>";
body += "REF: " + SOid + "<br \/>";
body += "<br \/>";
body += "Please review the items on order and contact us if you have any questions or require further information.<br \/>";
body += "<br \/>";
body += "<br \/>";
body += "<br \/>";
body += "<br \/>";
body += "Regards,<br \/>";
body += "<br \/>";
body += "Customer Service, <strong>One Weld<\/strong><br \/>";
body += "P: 1-866-663-9353<br \/>";
body += "F: 780-461-6293<br \/>";
body += "E: marketing@oneweld.ca<br \/>";
//send the PDF as an attachment
nlapiSendEmail('17994', email, subject, body, null, null, records, file); //change the value of author id.
} catch (e) {
nlapiLogExecution('ERROR', 'error@main', e);
}
}
/**
* Script Description
* To create email with CM attachment PDF
*
* Created on 17-Sep-2018
*/
/*******************************************************************************
* * Taipan Canada | TC-26 *
* **************************************************************************
*
*
* Author: Jobin & Jismi IT Services LLP
*
* REVISION HISTORY
*
*Ravin
*
******************************************************************************/
/**
* SCRIPT ID : { Name : TC-26 JJ WF-OW TC CM , ID :customscripttc_26_jj_wf_ow_tc_cm }
*
* DEPLOYMENT : { Title :TC-26 JJ WF-OW TC CM, ID :customdeploytc_26_jj_wf_ow_tc_cm }
*
*
*/
function SendEmailCM() {
try{
var id = nlapiGetRecordId();
var customer = nlapiGetFieldValue('entity');
var custom = nlapiLoadRecord('customer', customer);
var customer_id = custom.id;
var tran = nlapiGetFieldValue('tranid');
var website = custom.getFieldValue('custentity_website');
var total = nlapiGetFieldValue('total');
var setWebsite = website == "1" ? "One Weld" : "Taipan Canada";
var setSender = website == "1" ? "sales@oneweld.ca" : "ar@taipancanada.com"
var formnumber = website == "1" ? '121' : '106';
var email = custom.getFieldValue('custentity_ap_email') || custom.getFieldValue('email');
var phone = website == "1" ? "1-866-663-9353" : "1-855-461-6293";
var file = nlapiPrintRecord('TRANSACTION', id, 'PDF', { 'formnumber': formnumber });
var subject = website == "1" ? "Credit Memo #" + tran : "Credit Memo #" + tran;
var sender = website == "1" ? '6582' : '6563';
var body = "Hello,<br \/>";
body += "ATTN: Accounts Payable<br \/>";
body += "<br \/>";
body += "Thank you for your business!<br \/>";
body += "<br \/>";
body += "Your credit memo is attached:-<br \/>";
body += "REF: " + tran + "<br \/>";
body += "AMOUNT: " + total + "<br \/>";
body += "<br \/>";
body += "Please contact us if you have any questions or require further information.<br \/>";
body += "<br \/>";
body += "<br \/>";
body += "Regards,<br \/>";
body += "Accounts Receivable, <strong>" + setWebsite + "<\/strong><br \/>";
body += "P:"+ phone+"<br \/>";
body += "F: 780-461-6293<br \/>";
body += "E:" + setSender + "<br \/>";
var records = new Object();
records['entity'] = customer_id;
records['transaction'] = id;
//send the PDF as an attachment
nlapiSendEmail(sender, email, subject, body, null, null, records, file); //change the value of author id..
}
catch(e)
{
nlapiLogExecution('ERROR', 'error@main', e);
}
}
/**
* Script Description
* To create email with Estimate attachment PDF
*
* Created on 17-Sep-2018
*/
/*******************************************************************************
* * Taipan Canada | TC-26 *
* **************************************************************************
*
*
* Author: Jobin & Jismi IT Services LLP
*
* REVISION HISTORY
*
*Ravin
*
******************************************************************************/
/**
* SCRIPT ID : { Name : TC-26 JJ OW TC Estimate , ID :customscripttc_26_jj_ow_tc_estimate }
*
* DEPLOYMENT : { Title :TC-26 JJ OW TC Estimate, ID :customdeploytc_26_jj_ow_tc_estimate }
*
*
*/
function SendEmailEST() {
try {
var id = nlapiGetRecordId();
var customer = nlapiGetFieldValue("entity");
var custom = nlapiLoadRecord("customer", customer);
var customer_id = custom.id;
var email = custom.getFieldValue("email");
var tran = nlapiGetFieldValue("tranid");
var website = custom.getFieldValue("custentity_website");
var setWebsite = website == "1" ? "One Weld" : "Taipan Canada";
var setSender =
website == "1" ? "sales@oneweld.ca" : "sales@taipancanada.com";
var formnumber = website == "1" ? "123" : "103";
var phone = website == "1" ? "1-866-663-9353" : "1-855-461-6293";
var file = nlapiPrintRecord("TRANSACTION", id, "PDF", {
formnumber: formnumber
});
var subject = website == "1" ? "Estimate#" + tran : "Estimate#" + tran;
var sender = website == "1" ? "6582" : "6562";
var body = "Hello,<br />";
body += "<br />";
body += "Thank you for the opportunity to quote!<br />";
body += "Please review the attached estimate:-<br />";
body += "REF: " + tran + "<br />";
body += "<br />";
body += "<br />";
body +=
"Please contact us if you have any questions or require further information - we look forward to working with you!<br />";
body += "<br />";
body += "Regards,<br />";
body += "<br />";
body += "Customer Service, <strong>" + setWebsite + "</strong><br />";
body += "P: " + phone + "<br />";
body += "F: 780-461-6293<br />";
body += "E:" + setSender + "<br />";
var records = new Object();
records["entity"] = customer_id;
records["transaction"] = id;
//send the PDF as an attachment
nlapiSendEmail(sender, email, subject, body, null, null, records, file); //change the value of author id..
} catch (e) {
nlapiLogExecution("ERROR", "error@main", e);
}
}
/**
* Script Description
* To create email with Invoice attachment PDF
*
* Created on 17-Sep-2018
*/
/*******************************************************************************
* * Taipan Canada | TC-26 *
* **************************************************************************
*
*
* Author: Jobin & Jismi IT Services LLP
*
* REVISION HISTORY
*
*Ravin
*
******************************************************************************/
/**
* SCRIPT ID : { Name : TC-26 JJ WF-OW TC Invoice , ID :customscripttc_26_jj_wf_ow_tc_invoice }
*
* DEPLOYMENT : { Title :TC-26 JJ WF-OW TC Invoice, ID :customdeploytc_26_jj_wf_ow_tc_invoice }
*
*
*/
function SendEmailInvoice() {
try {
var id = nlapiGetRecordId();
var customer = nlapiGetFieldValue('entity');
var custom = nlapiLoadRecord('customer', customer);
var customer_id = custom.id;
var tran = nlapiGetFieldValue('tranid');
var website = custom.getFieldValue('custentity_website');
var due = nlapiGetFieldValue('duedate');
var setWebsite = website == "1" ? "One Weld" : "Taipan Canada";
var setSender = website == "1" ? "sales@oneweld.ca" : "ar@taipancanada.com"
var formnumber = website == "1" ? '118' : '102';
var email = custom.getFieldValue('custentity_ap_email') || custom.getFieldValue('email');
var phone = website == "1" ? "1-866-663-9353" : "1-855-461-6293";
var file = nlapiPrintRecord('TRANSACTION', id, 'PDF', { 'formnumber': formnumber });
var subject = website == "1" ? "Invoice #" + tran : "Invoice #" + tran;
var sender = website == "1" ? '6582' : '6563';
var body = "Hello,<br \/>";
body += "ATTN: Accounts Payable<br \/>";
body += "<br \/>";
body += "Thank you for your business!<br \/>";
body += "<br \/>";
body += "Please remit payment for the attached invoice as per agreed payment terms.<br \/>";
body += "REF: " + tran + "<br \/>";
body += "DUE DATE: " + due + "<br \/>";
body += "<br \/>";
body += "<br \/>";
body += "Regards,<br \/>";
body += "Accounts Receivable, <strong>" + setWebsite + "<\/strong><br \/>";
body += "P:"+ phone+"<br \/>";
body += "F: 780-461-6293<br \/>";
body += "E:" + setSender + "<br \/>";
var records = new Object();
records['entity'] = customer_id;
records['transaction'] = id;
//send the PDF as an attachment
nlapiSendEmail(sender, email, subject, body, null, null, records, file); //change the value of author id..
} catch (e) {
nlapiLogExecution('ERROR', 'error@main', e);
}
}
/**
* Script Description
* To create email with SO attachment PDF
*
* Created on 17-Sep-2018
*/
/*******************************************************************************
* * Taipan Canada | TC-26 *
* **************************************************************************
*
*
* Author: Jobin & Jismi IT Services LLP
*
* REVISION HISTORY
*
*Ravin
*
******************************************************************************/
/**
* SCRIPT ID : { Name : TC-26 JJ WF-OW TC SO , ID :customscripttc_26_jj_wf_ow_tc_so }
*
* DEPLOYMENT : { Title :TC-26 JJ WF-OW TC SO, ID :customdeploytc_26_jj_wf_ow_tc_so }
*
*
*/
function SendEmailSO() {
try {
var id = nlapiGetRecordId();
var customer = nlapiGetFieldValue('entity');
var custom = nlapiLoadRecord('customer', customer);
var customer_id = custom.id;
var email = nlapiGetFieldValue('email');
var tran = nlapiGetFieldValue('tranid');
var website = custom.getFieldValue('custentity_website');
var setWebsite = website == "1" ? "One Weld" : "Taipan Canada";
var setSender = website == "1" ? "marketing@oneweld.ca" : "sales@taipancanada.com"
var formnumber = website == "1" ? '100' : '101';
var phone = website == "1" ? "1-866-663-9353" : "1-855-461-6293";
var file = nlapiPrintRecord('TRANSACTION', id, 'PDF', { 'formnumber': formnumber });
var subject = website == "1" ? "Sales Order #" + tran : "Sales Order #" + tran;
var sender = website == "1" ? '17994' : '6562';
var body = "Hello,<br \/>";
body += "<br \/>";
body += "Thank you for your business!<br \/>";
body += "REF: " + tran + "<br \/>";
body += "<br \/>";
body += "Please review the items on order and contact us if you have any questions or require further information.<br \/>";
body += "<br \/>";
body += "<br \/>";
body += "Regards,<br \/>";
body += "Customer Service, <strong>" + setWebsite + "<\/strong><br \/>";
body += "P:"+ phone+"<br \/>";
body += "F: 780-461-6293<br \/>";
body += "E:" + setSender + "<br \/>";
var records = new Object();
records['entity'] = customer_id;
records['transaction'] = id;
//send the PDF as an attachment
nlapiSendEmail(sender, email, subject, body, null, null, records, file); //change the value of author id..
} catch (e) {
nlapiLogExecution('ERROR', 'error@main', e);
}
}