You need to sign in to do that
Don't have an account?
Bernie X
OrgWideEmailAddress x Javascript reference
I'd like to have a button send an e-mail, after an onclick. I've setup my OrgWideEmailAddress in my sandbox, and can access its ID via SOQL query. Using the an embedded sendemail API call in Javascript, I get the following error {faultcode:'soapenv:Client', faultstring:'Element {urn:partner.soap.sforce.com}OrgWideEmailAddressId invalid at this location', }. Can't figure out even what this error means...this location?
Please share your javascript code, how are you referring this field in your code.
Thanks for you reply. Here's my JavaScript:
{!REQUIRESCRIPT ("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
function log(message) {
alert(message);
}
var d = sforce.connection.query("select ID from OrgWideEmailAddress");
var records = d.getArray("records");
sforce.debug.log(d.length);
for(var i=0;i<records.length;i++){
var record = records[i];
sforce.debug.log(record.Id);
var e = record.Id;
}
var c = "{!Customer_Correspondences_and_Complaints__c.Name}";
var s = new sforce.SingleEmailMessage();
s.replyTo="berniex@google.com";
s.subject = "Complaint # " + complaint + " is ready for review";
s.OrgWideEmailAddressId = e;
s.plainTextBody = "Complaint # " + c + " is ready for review.\n\nUse the link below to review this complaint.\n\n" + document.URL +"\n\nRegards,\n\n"+"{!$User.FirstName}";
s.toAddresses = ["berniex@google.com"];
sforce.debug.log(s);
var t = sforce.connection.sendEmail([s]);
I have three suggestions:
1) Move variable e out of For loop and declare it outside.
2) Try checking value of all the variables using alert staement.
3) Try hardcoding an email address to check if code is working fine and issue is with orgwideemailAddress
Thanks for your reply. I have tried # 2 and # 3 already (the debug.log commands work similar to alerts and the code works if I don't declare orgwideemailAddressId). Will give # 1 a shot.