Solved

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

Posted on 2012-04-05
10
708 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to count occurrences of each item in an array.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

615 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