Solved

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

Posted on 2012-04-05
10
685 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
  • 5
  • 5
10 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
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
Comment Utility
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
Comment Utility
nlapiGetFieldValue is not there.
0
 

Author Comment

by:prileyosborne
Comment Utility
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
Comment Utility
Impossible to say what is going on with the snippet of code you gave. Sorry
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:prileyosborne
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks so much for all your help!
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now