PDA

View Full Version : javascript referencing extrenal database



tunedog_07
11-30-2007, 12:02 AM
I am having some difficulty with this script.
It was sent to me by a colleague to modify. There may be some redundant code there, as I only need a small part of what it originally did and have removed what I considered to be irrelevant.

I think I am close - but I keep getting a syntax error.

The DB is a Salesforce.com account.

Any help would be greatly appreciated!!!



{!REQUIRESCRIPT("/soap/ajax/9.0/connection.js")}

var records = {!GETRECORDIDS($ObjectType.Participants__c)};

if (records[0] == null) {
alert("Please select at least one attendee to email.");
}
else {
for ( var contactQR = sforce.connection.query("SELECT Participant FROM Participant__c Where Id = '" + contactName+ "'");
var contactName = contactQR.getArray('records')[0].Participant__c;

//Bind and send email
var singleEmailRequest = new sforce.SingleEmailMessage();

singleEmailRequest.charset = "UTF8";
singleEmailRequest.subject = "";
singleEmailRequest.saveAsActivity = true;
singleEmailRequest.targetObjectId = participant__c;

singleEmailRequest.htmlBody = "<font face=arial size=2><img src='https://emea.salesforce.com/servlet/servlet.FileDownload?file=015200000008PB3' border='0'>" +

//singleEmailRequest.plainTextBody = "Plain text body";
sendEmailResults = sforce.connection.sendEmail([singleEmailRequest]);
}

alert("Your emails has been successfully sent to selected attendees.");
}

Replaced blinding [icode] with [code]

djr33
11-30-2007, 01:23 AM
By the way, you should probably use [code] for long blocks of code. [icode] is better for shorter blocks.


Honestly, I don't recognize that style of Javascript. Javascript cannot connect to a database, though some variation may be able to. Is this ActiveX, and therefore reliant upon Internet Explorer?

I assume someone will be able to help more.

This looks like some odd mix of Javascript and ASP, to me.