I couldn't find an answer to this in docs or here. Is it possible to script sending statements to customers? thanks for any help you can give.
Yes, but it's even easier to do it with a workflow. We created a custom field for a 'Statement Contact' and set up a scheduled workflow based on a 'Saved Search Filter' which basically checks that the customer has a balance. There is one state which contains a single 'Send Email' action. The 'Send Email' action has the option to 'Include Statement'. It fires on the 4th day of each month - you can set this or any other parameter to whatever suits you. This works fine for us, so I hope it helps you.
I found this in SuiteAnswers, it is enough for my purposes.
function printStatement()
{
//this is is the customer id
var id = nlapiGetRecordId();
var email = nlapiGetFieldValue('custentity_accounting_email');
//create an array to set the STATEMENT properties(optional)
var sdate = new Array();
sdate.startdate = '11/01/2015'; // replace it as per requirement
sdate.statementdate = '11/30/2015'; // replace it as per requirement
sdate.openonly = 'T'; // replace it as per requirement
sdate.formnuber = 112; // replace it as per requirement
//print the statement to a PDF file object
var file = nlapiPrintRecord('STATEMENT', id, 'PDF', sdate);
//send the PDF as an attachment
nlapiSendEmail('-5', email, 'Regular Statement', 'Please see attached Statment', null, null, null, file); //change the value of author id.
}
Related
I'm trying to create calendar events in sheets using Google App Script (I'm very new to this). The sheet contains details of the event (date, time, event title, and guest list) as well as the calendar ID (this is a training calendar). I want to make it simple for the end-user to fill in the information on the sheet, click 'schedule now' and the script run and send the events out to all email addresses mentioned in the guest list.
Here is an example of the sheet:
Here is a copy of the code (I found this on the Google Developer website and tried to adapt it to add guests but haven't been able to get it working and really not sure where to go with this. Ideally, I'd like the guest list to come from the sheet and not be written into the code as an option.
function scheduleTraining() {
var spreadsheet = SpreadsheetApp.getActiveSheet();
var calendarId = spreadsheet.getRange("C3").getValue();
var eventCal = CalendarApp.getCalendarById(calendarId);
Logger.log(eventCal)
var signups = spreadsheet.getRange("A5:C20").getValues();
for (x=0; x<signups.length; x++) {
var shift = signups[x];
var startTime = shift[0]
var endTime = shift[1]
var title = shift[2]
eventCal.createEvent(title, startTime, endTime, {
location: 'remote',
description: 'snacks provided',
})
}
}
function onOpen(e) {
SpreadsheetApp.getUi()
.createMenu('Schedule Training')
.addItem('Schedule Now', 'scheduleTraining')
.addToUi();
}
If anyone can help with this or has any ideas on how to do this better, I'm all ears!
Thanks!
Issues:
The dates in your spreadsheet file are strings/texts. You can verify that if you do =isDate(A7). If the latter returns FALSE then you don't have a valid date object. If you see the official documentation you need to pass date objects and not date texts.
Another remark I have is that your range is "A5:C20" but you should start from A7. Row 5 and 6 don't contain the information required, according to your screenshot.
Question based on your comment:
how I can include inviting the guests when it's run
Again according to the documentation, you can add guests using the advanced parameters options and in particular guests:
eventCal.createEvent(title, startTime, endTime, {
location: 'remote',
description: 'snacks provided',
guests: 'test1#gmail.com,test2#gmail.com'
})
guests is a type of string that contains a comma-separated list of email addresses
that should be added as guests.
I am attempting to validate a form field for an SCA (mont-blanc) site.
As I am not versed in SuiteScript code, but know Java, I simply need to know how to retrieve the POST value of a form field, so that I can do a check on the submission before submitting the form.
The below is not working - simply because I don't know the function / method to call to get the email address that is being submitted.
name: 'ContactUs',
create: function create( data ) {
try {
url = '<the-url>';
var email = nlapiGetContext.getEmail();
if (email.indexOf("qq.com") === -1) {
response = nlapiRequestURL(url, data);
responseCode = parseInt(respons...
To validate any field data you need to use client-script on the said record and based on your code and requirement, I think you want to validate Suitelet data(right?).
You can deploy client script on any record/suitelet and validate field data in saveRecord method. You can find client script help doc here.
Detecting the value in a data field in a submitted form is as simple as data['field_name']
In the above example - it would be:
name: 'ContactUs',
create: function create( data ) {
try {
url = '<the-url>';
**var email = data['email'];**
if (email.indexOf("qq.com") === -1) {
response = nlapiRequestURL(url, data);
responseCode = parseInt(respons...
My objective is to respond to a picked event in an external system and mark the SalesOrder "Picked" in NetSuite and later respond to a pack event in an external system and mark the SalesOrder "Packed" in NetSuite.
I am using the code from the SuiteTalk sample application. I first get a copy of the existing ItemFulfillment record and then populate a new ItemFulfillment record.
The code works great when I respond to the pick event. Unfortunately, when I respond to the pack event, when I try to get a copy of the existing ItemFulfillment Record for the SalesOrder I get this error.
"You must have at least one valid line item for this transaction."
I assumed that NetSuite is complaining that there are no more line items to fulfill, so I tried not adding any ItemFulfillmentItem(s) when I set the status to picked, but NetSuite didn't like that either.
The only documentation that I could find referenced a task Id, /app/accounting/transactions/itemshipmanager.nl?type=pack. This approach seemed credible because when I brought up Fiddler, this is the call that it made when I click the "Mark Packed" button in the UI. However, I would prefer not to introduce a different paradigm for talking to the NetSuite server.
I have found that NetSuite will let me go straight to the Pack state if I set shipStatus and shipStatusSpecified in the ItemFulfillment.
Can I move a SalesOrder through both the picked and packed states using only NetSuite SuiteTalk?
I was going about the problem incorrectly. Instead of adding items to a new packed item fulfillment, the correct approach is to find the existing ItemFulfillment and change its status to packed.
This is the search that finds an existing ItemFulfillment for a SalesOrder:
TransactionSearch xactionSearch = new TransactionSearch
{
basic = new TransactionSearchBasic
{
type = new SearchEnumMultiSelectField
{
#operator = SearchEnumMultiSelectFieldOperator.anyOf,
operatorSpecified = true,
searchValue = new System.String[]
{
"_itemFulfillment"
}
},
createdFrom = new SearchMultiSelectField
{
#operator = SearchMultiSelectFieldOperator.anyOf,
operatorSpecified = true,
searchValue = new RecordRef[1]
{
new RecordRef
{
internalId = salesOrderInternalId,
type = RecordType.salesOrder,
typeSpecified = true
}
}
}
}
};
This is the code that updates the ItemFulfillment:
ItemFulfillment update = new ItemFulfillment { internalId = existing.internalId, shipStatus = status, shipStatusSpecified = true };
WriteResponse res = _service.update(update);
Can someone help me to work my task on netsuite Sending email. The email body should be generated with the freemarker template engine using nlapiCreateTemplateRenderer. I try to used the sample on the help page in netsuite but it doesnt work. Can somebody explain or give me a example on this API.
By the way i can sent email using suitelet, my problem is the email body.
Thank you.
Provided that you have your scriptable template. This should run OK.
var emailTempId = 1; // internal id of the email template
var emailTemp = nlapiLoadRecord('emailtemplate',emailTempId);
var emailSubj = emailTemp.getFieldValue('subject');
var emailBody = emailTemp.getFieldValue('content');
var records = new Object();
records['transaction'] = '1'; //internal id of Transaction
var salesOrder = nlapiLoadRecord('salesorder', 1);
var renderer = nlapiCreateTemplateRenderer();
renderer.addRecord('transaction', salesOrder );
renderer.setTemplate(emailSubj);
renderSubj = renderer.renderToString();
renderer.setTemplate(emailBody);
renderBody = renderer.renderToString();
nlapiSendEmail(-5, 'email#domain.com', renderSubj, renderBody , null, null, records);
The new Scriptable Template that is using the FreeMarker only supports Entity, Transaction, Custom Record, Case, & Project Record. Other records might work but based on Answer Id: 32621 from the SuiteAnswers those record are the ones that will be supported.
I was looking the way to create a Task from an email at my Google Account with a filter. I've read this tutorial and it worked like a charm: http://www.pipetree.com/qmacro/blog/2011/10/automated-email-to-task-mechanism-with-google-apps-script/
The only bad thing is that the script creates a task with the subject of the message, and it's not really descriptive for me, because they are automatic messages, and all of them have the same subject.
I want the Task Title be a specific line of the email body, can anybody helpme with this?
Yes, basically you would get the message body and extract what you need from it. I'm not sure about the structure of your email but you need something in there that tells you the start and end of the task title, once you tell me what it is i can incorporate it in to the code. For now this is how you would set the body as the title.
var message = thread.getMessages()[0]; // get first message
var messagebody = message.getBody();
var body_array = messagebody.split('Sender:');
var taskTitle = '';
if( body_array.length < 2 )
taskTitle = 'No title specified in email after Sender:';
else
{
var text = body_array[1];
taskTitle = text.split('<br />')[0].trim();
}