• wick
  • NEWBIE
  • 30 Points
  • Member since 2008

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies
These boards have numerous threads about sending emails from s-controls.  Having just wrestled with a variant of the problem for a customer, I thought I'd post the solution I used, which (now!) seems fairly straightforward (although it took some bobbing & weaving to get here).

Problem Statement
:  With one click, allow a user to create an object, then send a template-based email to a Contact associated with that object.  The email template must populate with correct values from the just-created object.

Solution:  Save the following code as an s-control snippet.  Then include the snippet, and call the function from anywhere in your main s-control.  (I won't cover the part about creating a new object here - let's assume you can do that, and then retrieve the object ID of your newly created object.)

function sendEmail(templateId, contactIdForToAddress, relatedObjectId) {

  var url = "https://na3.salesforce.com/email/author/emailauthor.jsp?";
  url += "p2_lkid=" + contactIdForToAddress;
  url += "&p3_lkid=" + relatedObjectId;
  url += "&template_id=" + templateId;
  url += "&new_template=1";
  url += "&retURL=%2F" + relatedObjectId;
  url += "&nosave=0";   // not sure what this parameter does, or if it's really needed
  url += "&save=1";   // send it now - don't just bring us to the "send email" page

  window.open(url);
}


The net effect here is that a new window (actually, a tab in Firefox) will open up, pointing at the newly created object.  If it has an Activity History related list, the just-sent email will appear there. 

This all worked rather elegantly for me.  The actual use case is a Google Map showing the location of various Communities (a custom object).  The user can select several Communities (from a sidebar with a list of accounts & checkboxes), then click a single button to create "Referrals" (a custom object) to each selected Community, and email each Community's primary contact with their Referral data.  After the click, the user waits a moment, and then multiple tabs open up, one for each newly-created Referral.

I'm happy to discuss further if anyone is interested or needs help doing something similar - glenn@appirio.com.


Message Edited by GlennAtAppirio on 02-18-2007 01:05 PM

Message Edited by GlennAtAppirio on 02-18-2007 01:05 PM

I have created a custom object that hangs off of the case object.

When the user creates a new record on the custom reltaed list and hits save it leaves them on the newly created record
nsted of redirecting them back to the case.

The user can always click the link to the case but that is an extra step and not the same functionality that exists with other
related lists.

I would like this to work the same as creating a new task for the case.  Afetr you save the new task it takes you back to the
case instead of leaving you on the newly created task.

Any ideas on how I can do this?
  • June 12, 2008
  • Like
  • 0
Is there a way to use formulas in Email templates to handle conditional formatting?

For example, I'd like to use the formula UPPER( NAME HERE ) to cause the person's name to appear in all CAPS, even though it may appear as "Name Here" in the SFDC database. This is just one example.

Furthermore, there may be conditions upon which you do or do not want to show certain information in an email response. Using formulas would be helpful. I didn't see any documentation on this when search for "formulas in email templates" -- so I'm not sure if it's possible.

Thanks.
I am trying to migrate some data from one SF account to another and after failed effort at using the Excel connector moved on to try the APex Data Loader with Data Export data from Account A. WHen I tried to use the Data Loader to insert the Account data object into Account B I was getting 100% "invalid cross reference id" errors. Upon further inspection of the error file I notice some "insufficient access rights on cross-reference id" errors as well. I googled and came across a thread on here that the problem may be related to OWNERID field. So I removed that field form the mapping and near 100% success. Alas I am still getting the "insufficient access rights on cross-reference id" errors. The other error has vanished.

Does anyone have any idea what could be done to resolve this as no one at SF seems to have a clue?
  • May 01, 2008
  • Like
  • 0
I've set up a custom button to clone account records (don't ask - it's a long story).  Everything checks out ok but I can't get a multi-select field to pass through to the new record.  I've tried everything.  Here's what I am using.  The bold red line is the one that isn't working.

https://na2.salesforce.com/001/e?
acc2={!Account.Name}&
00N30000000lVLT_selected={!Account.Ranking__c}&
00N30000000lsJD={!Account.Fortune_Rank__c}&
acc12={!Account.Website}&
acc17street={!Account.BillingStreet}&
acc17city={!Account.BillingCity}&
acc17state={!Account.BillingState}&
acc17zip={!Account.BillingPostalCode}&
acc17country={!Account.BillingCountry}&
acc7={!Account.Industry}&
acc15={!Account.NumberOfEmployees}&
00N40000001LlGl={!Account.of_Employees__c}

Thanks.

Lee

These boards have numerous threads about sending emails from s-controls.  Having just wrestled with a variant of the problem for a customer, I thought I'd post the solution I used, which (now!) seems fairly straightforward (although it took some bobbing & weaving to get here).

Problem Statement
:  With one click, allow a user to create an object, then send a template-based email to a Contact associated with that object.  The email template must populate with correct values from the just-created object.

Solution:  Save the following code as an s-control snippet.  Then include the snippet, and call the function from anywhere in your main s-control.  (I won't cover the part about creating a new object here - let's assume you can do that, and then retrieve the object ID of your newly created object.)

function sendEmail(templateId, contactIdForToAddress, relatedObjectId) {

  var url = "https://na3.salesforce.com/email/author/emailauthor.jsp?";
  url += "p2_lkid=" + contactIdForToAddress;
  url += "&p3_lkid=" + relatedObjectId;
  url += "&template_id=" + templateId;
  url += "&new_template=1";
  url += "&retURL=%2F" + relatedObjectId;
  url += "&nosave=0";   // not sure what this parameter does, or if it's really needed
  url += "&save=1";   // send it now - don't just bring us to the "send email" page

  window.open(url);
}


The net effect here is that a new window (actually, a tab in Firefox) will open up, pointing at the newly created object.  If it has an Activity History related list, the just-sent email will appear there. 

This all worked rather elegantly for me.  The actual use case is a Google Map showing the location of various Communities (a custom object).  The user can select several Communities (from a sidebar with a list of accounts & checkboxes), then click a single button to create "Referrals" (a custom object) to each selected Community, and email each Community's primary contact with their Referral data.  After the click, the user waits a moment, and then multiple tabs open up, one for each newly-created Referral.

I'm happy to discuss further if anyone is interested or needs help doing something similar - glenn@appirio.com.


Message Edited by GlennAtAppirio on 02-18-2007 01:05 PM

Message Edited by GlennAtAppirio on 02-18-2007 01:05 PM