Solved

[javascript] Getting missing ; before statement (debugger$debugger.user#13)

Posted on 2012-04-05
10
697 Views
Last Modified: 2012-04-12
I am getting the following error:

missing ; before statement (debugger$debugger.user#13)

when I send my code through the SuiteScript debugger.  Since it is basically just JavaScript, I was hoping someone might know what the issue is. Below is my code:

function psTrigEmail(type)
{
	var proSupportMail 		= ['Pro Services Premium','Pro Services Basic'];
	var proSupport_set		= nlapiGetFieldValue('custmomer.custentitysc_type');
	var proSupport_confirm	= nlapiGetFieldValue('contact.custentity30');

	//boolean value to check if Welcome Message was sent before
	var bolTermSent = (nlapiGetFieldValue('custentity_terms_email') && nlapiGetFieldValue('custentity_terms_email')=='T' ));
	var bolWelSent 	= (nlapiGetFieldValue('custentity_welcome_email') && nlapiGetFieldValue('custentity_welcome_email')=='T'));
	//internal ID of email template to merge with.
	var ps_termsEmail = '94';
	var ps_welEmail = '95';

	//uses bolTermSent and bolWelSent functions and checks the status of the two 
	if ((!bolTermSent || !bolWelSent) && (proSupport_set.stringContains(status) && proSupport_confirm.stringContains(status))
	{
		// Get customer Point Of Contact email and send first email to them.
		//conduct mail merge with this customer record by calling
		//nlapiMergeRecord() method.
		//nlapiGetNewRecord().getId() returns internal ID of this record.
		var mail = nlapiMergeRecord(ps_termsEmail,'customer', nlapiGetNewRecord().getId());
		//return value of Subject from Email Template
		var sbj = mail.getName();
		//return value of Message body from Email Template
		var msg = mail.getValue();
		//set sendto as Internal ID of this customer.
		//	- Using this method allows customers' response (When Reply is used) is automatically logged
		//	- This method also automatically attaches this message to THIS customer
		var sendto = nlapiGetNewRecord().getId();

		//Send out the email using nlapiSendEmail
		nlapiSendEmail('-5',sendto,sbj,msg,null,null,null,null);

		//update Welcome Message Sent flag.
		nlapiSubmitField('customer',nlapiGetNewRecord().getId(),'custentity_welcome_email','T');

		alert ("Pro Support declared and POC set and emails have not been sent.");
	};
};

Open in new window

0
Comment
Question by:prileyosborne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37812709
Please load your page into Firefox and look in the console.

you have a lot of code you did not show
0
 

Author Comment

by:prileyosborne
ID: 37813055
Actually, that could be my issue.  This is the only script, except for a library script that has this function:

function stringContains(superstring, substring){
	if (superstring.indexOf(substring) !== -1){
	return true;
	}
	return false;
}

Open in new window


I will look into the firefox console and see what I can find. Thank you!
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37813397
nlapiGetFieldValue is not there.
0
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 

Author Comment

by:prileyosborne
ID: 37817763
That is actually from the NetSuite API... sorry, this is using the NetSuite API to generate many of the custom function calls.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37818306
Impossible to say what is going on with the snippet of code you gave. Sorry
0
 

Author Comment

by:prileyosborne
ID: 37833760
Thanks for the feedback!  To make sure that this is not a total waste and to get you some points for your time, I have updated my script a bit but I have a question on two parts:

I have a series of variables that use calls from the NetSuite API:

var proSupportMail 	= ['Pro Premium','Pro Plus','Pro Basic'];
var proSupport_set		= nlapiGetFieldValue('custmomer.custentitysc_type');

Open in new window


I have a conditional statement that I want to have triggered by the variable proSupport_set equaling any of the three proSupportMail values.  How would you write a statement like that?

I am not sure if I will need to write a custom function that compares the two and looks for any similarities or if there is a way to write it like:

proSupport_set    = proSupportMail

Open in new window


If I need to write a function, any hints on where to start. i am not very versed in JavaScript so any help is appreciated.  Thanks!
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 37833923
I think you mean something like this

function isPro(str) {
  for (var i=0;i<proSupportMail.length;i++) {
    if (str==proSupportMail[i]) return true; // yes we found it
  }
  return false; // not found
}

var proSupportMail = ['Pro Premium','Pro Plus','Pro Basic'];
var proSupport_set  = nlapiGetFieldValue('custmomer.custentitysc_type');
if ( isPro(proSupport_set)) {
  alert("Yes we found Pro")
}

Open in new window


or simpler (assuming you do not have something like "Product")
if (proSupport_set.indexof("Pro")==0) {
  alert("we found Pro as the first part of the set")
}

Open in new window

0
 

Author Comment

by:prileyosborne
ID: 37834060
So awesome, that works perfectly! The first solution was actually perfect.

I have one quick question in terms of the function.

The for statement is basically loading each of the options for the variable into an array and then when you run the function on the other variable, it just matches that variable to any one of the results in the array?

I just want to make sure I understand the method in case I have to update it...  Thanks again!
0
 

Author Closing Comment

by:prileyosborne
ID: 37838452
Thanks so much for all your help!
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37839070
The for statement compares the value given with each of the items in the array and stops when found and returns true - if not found it returns false
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JS library vs Js framework 11 22
CSV file copy field 1 to field 2 2 36
Error when Running powershell script 6 29
Table header must be on top 2 26
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question