How NetSuite Schedule Scripts Help Notify Customers on Upcoming Invoices Due
NetSuite
TMnow | 27 May 2023
Introduction
Why is a Schedule Script necessary?
For this Customization we use
Schedule Script
Benefits of using Schedule Script in NetSuite:
Sample Use Case:
Here is an example of Reminding customers of the impending invoice due date prior to 5,10,15.
Implementation Process:
Recommended by LinkedIn
var transactionSearchObj = search.create(
type: "transaction",
filters:
[
[["status","anyof","CustInvc:A"],"AND",["mainline","is","T"]],
"AND",
[[["formulanumeric: ROUND({duedate}-{today})","equalto","5",]],"OR",
[["formulanumeric:ROUND({duedate}-{today})","equalto","10"]],"OR",
[["formulanumeric: ROUND({duedate}-{today})","equalto","15"]]]
],
columns:
[
search.createColumn({name: "internalid", label: "Internal ID"}),
search.createColumn({name: "custcol_2663_companyname",
label: "Company Name"}),
search.createColumn({name: "custbody22",
label: "Created __by"}),
search.createColumn({name: "supervisor",
join: "CUSTBODY22",
label: "Supervisor"
}),
search.createColumn({name: "tranid",
label: "Document Number"}),
search.createColumn({name: "internalid",
join: "customerMain",
label: "Internal ID"
}),
search.createColumn({name: "formulanumeric",
formula: "ROUND({today}-{duedate})",
label: "today-duedate"
}),
search.createColumn({name: "email",
join: "customerMain",
label: "Email"
})
]
});
{
Obj_key=receiverEmail
Obj_values={
"internalid":recordid,
"createdby":createdby,
"Supervisor":supervisor,
"link":link,
"Doc_Num":document number,
"days overdue":days_due,
"Customer_internalid":customer
};
if (Obj_map[Obj_key] == undefined) {
Obj_map[Obj_key] = [Obj_values]
}
else {
Obj_map[Obj_key].push(Obj_values);
};
Var customer=Object.values(Obj_map);
var to_email=Object.keys(Obj_map);
var table='';
table+='<html><style>table, th, td {border:1px solid black,class="sortable";}';
table +='</style>';
table +='<body>';
table +='<h2>Invoices</h2>';
table +='<table style="width:100%">';
table +='<tr>';
table +='<th>Document Number</th>';
table +='<th>Days Over Due</th>';
table +='<th>link</th>';
table +='</tr>';
for(i=0;i<cstomer.length;i++)
{
log.debug('why are you looping IIIII'+i);
// log.debug('inside for values',cstomer[i]);
var x=cstomer[i];
var customer_internalid=x.Customer_internalid;
var documentnumber=x.Doc_Num;
var link=x.link;
var created=x.createdby;
var customermail=x.customeremail;
var overduedays=x.daysoverdue;
var int_id=x.internalid;
table +='<tr>'
table +='<td>'+documentnumber+'</td>';
table +='<td>'+overduedays+'</td>';
table +='<td>'+link+'</td>';
table +='</tr>';
}
table +='</table>';
table +='</body>';
table +='</html>';
var emailBody = "These invoices Will be overdue in #"+table;
var author=A/P_Analist;
email.send({
author:author,
recipients:to_email,
subject: emailSubject,
body: emailBody,
relatedRecords:{entityId:author,
entityId:customer_internalid
}
});;
FAQ
More Questions?
Visit: www.techmantranow.com
--------------------------------------------------------------------------------
Need help selecting the right enterprise products & solutions for your business? Connect with TechMantra Now's Cloud ERP Software experts!