I am having difficulties getting the Communities Welcome email to send to new users added to the community. What happens is that we insert a lead via a web-to-lead form that is inserted with a guest user license. When the lead is inserted into Salesforce, if not a duplicate it will automatically convert to a contact and create an opportunity. There are more formulas in place to determine to create a community user in code. This all happens at once and is created by the guest user. As it is with Communities, if a user is created by another user who does not have the Create or Manage Communities permission, the user is still added to the community, however, no welcome email is sent. In an attempt to work around this issue, I tried creating a workflow rule on the user to send the Welcome email template on create a field is set to 'Yes' and the Profile is set to the community profile. When I tested this, no email was sent. I checked the debug logs and something resulted in a null reference exception. Since this code has been working before, I'm assuming that the null reference exception came from trying to use the {!Community.[field]} in the email template.

Is there a way to force this email template to send in apex code where I can associate it to the correct Network (Community) AND User? When looking at the send email methods that you can use in apex, it refers to a TartgetObjId, which is the id that will be receiving the email. I don't feel like that will associate the user to the corresponding community.


  • Since leads can not actually be members of a community, only contacts, can you explain exactly how the Communities user is created? What is the internal process? Does it differ with non-admins?
    – greenstork
    Jun 2, 2014 at 20:56
  • The lead is getting automatically converted to a contact as soon as it is entered in salesforce. So, we are creating a community user off the new contact that is created.
    – JRiffe
    Jun 2, 2014 at 21:06
  • I see where I made my initial comment confusing. Had communities on the brain. I will edit that to say Salesforce instead of Community.
    – JRiffe
    Jun 2, 2014 at 21:07
  • What does automatically converted mean? Via a trigger?
    – greenstork
    Jun 2, 2014 at 21:27
  • We have code in place that uses the Database.convertLead() method. Yes it is triggered by a trigger.
    – JRiffe
    Jun 2, 2014 at 21:44

1 Answer 1


I was unable to find a direct way to get around this issue.

The work around that I used was to create 6 jobs with the intervals of on the hour, 10 after the hour, 20 after the hour, etc that will check my portal user indicator. If it is not set to 'Yes', then it will set it and create the portal user and the Welcome email will be generated.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .