Ok I have a script that is deployed into a portlet that allows customers (when logged in) to upload a file so it appears under the file tab on their record.
I was trying to use a saved search to then send an email to an individual (dependent on the customer category) to notify them of the added file. It seems however that saved searches only work in this way if you have gone in and added the file manuallly (not via a script).
so i've tried to pass the category variable from a web page to the portlet then send an email to the invidual dependent on the category. The problem is i am struggling to get it working.
here is where i am at the moment:
// JavaScript Document function uploader(request, response) { if (request.getMethod() == 'GET') { var form = nlapiCreateForm('Upload your plans', false); var params = request.getAllParameters(); var entityURL = params['entityURL']; //var entityURL = request.getParameter('LiveID'); var entityField = form.addField('entity', 'text', 'Customer', 'customer'); entityField.setLayoutType('normal', 'startcol') entityField.setDefaultValue(entityURL) entityField.setDisplayType('hidden') entityField.setMandatory(false) var fileField = form.addField('file', 'file', 'Select File'); fileField.setMandatory(true) form.addSubmitButton(); form.addResetButton(); response.writePage(form); } else { var entity = request.getParameter("entity") var file = request.getFile("file") // set the folder where this file will be added. In this case, 10 is the internal ID // of the SuiteScripts folder in the file cabinet //file.setName("file" + entity + ".jpg") //set file name file.setName(entity + "-" + file.getName()) file.setFolder(22012) // now create file and upload it to the file cabinet. You must use nalpiSubmitFile // to upload a file to the file cabinet. See nlapiSubmitFile(file). var id = nlapiSubmitFile(file) // now attach file to customer record nlapiAttachRecord("file", id, "customer", entity) //nlapiAttachRecord("file1", id1, "customer", entity)// now navigate to customer record //response.sendRedirect('record', 'customer', entity) //response.sendRedirect('record', 'customer', entity) //work starts here for the mailing code var params = request.getAllParameters(); var facategory = params['category']; if (facategory=="Plumbing / Installer" ) { var body1 = 'Files have been submitted. To view the files please visit the <a href="https://system2.netsuite.com/app/common/entity/custjob.nl?id='; var body4 = '">record</a> and look under the files tab.'; nlapiSendEmail(47438, 'rob.mccreedie@nu-heat.co.uk', 'File Submission Notification'+facategory, body1+entity+'">record</a>', null, null, null); } else if (facategory=="Self Builder") { var body1 = 'Files have been submitted to view the files please visit the <a href="https://system2.netsuite.com/app/common/entity/custjob.nl?id='; var body4 = '">record</a>'; nlapiSendEmail(47438, 'rob@mccreedie.co.uk', 'File Submission Notification', body1+entity+'">record</a>', null, null, null); } var html = '<br /><br /><br /><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #333333;">Your upload is complete. '+facategory+'</span><br /><br />'; var fhform = nlapiCreateForm('Thank you', 'false'); var field = fhform.addField('thankyou','inlinehtml', 'thankyou'); field.setDefaultValue(html); response.writePage(fhform); } } it won't send an email at all which is most frustrating.here is the url that links to the portlet:https://forms.netsuite.com/app/site/hosting/scriptlet.nl?script=106&deploy=1&compid=472052&h=724552bb5d9dc765ad6c&entityURL=141856&category=Plumbing / Installer
i've been going round in circles and it's been driving me mad, any pointers would be well received