Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 741
  • Last Modified:

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

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
prileyosborne
Asked:
prileyosborne
  • 5
  • 5
1 Solution
 
Michel PlungjanIT ExpertCommented:
Please load your page into Firefox and look in the console.

you have a lot of code you did not show
0
 
prileyosborneAuthor Commented:
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
 
Michel PlungjanIT ExpertCommented:
nlapiGetFieldValue is not there.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
prileyosborneAuthor Commented:
That is actually from the NetSuite API... sorry, this is using the NetSuite API to generate many of the custom function calls.
0
 
Michel PlungjanIT ExpertCommented:
Impossible to say what is going on with the snippet of code you gave. Sorry
0
 
prileyosborneAuthor Commented:
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
 
Michel PlungjanIT ExpertCommented:
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
 
prileyosborneAuthor Commented:
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
 
prileyosborneAuthor Commented:
Thanks so much for all your help!
0
 
Michel PlungjanIT ExpertCommented:
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now