1

I am working on communities customer portal. I have created a email template for reset password for customer. when ever email triggered username is blank for username am using :{!Receiving_User.Username} merge field if i replace it with : {!user.username } it populating current user username but i need customer username please help me on this

FYI: For portal users, the Receiving_User is actually pulling fields from the Contact object, not from the User object. Even the standard fields are from the Contact, not from the User.

bellow is my code:

Dear {!Receiving_User.FirstName} {!Receiving_User.LastName}, ----> first name and last name populating correct

Username:{!Receiving_User.Username}

Login with temporary password link generated by system:{!Community_Url}

Please log into your account with the credentials listed above. You will be asked to set a new password when you log in. If you have any questions, please contact me.

Best regards, {!User.FirstName} {!User.LastName} {!User.Title} {!User.Phone} {!User.Email} {!Organization.Name}

3 Answers 3

1

As you pointed out, the Receiving_User is actually a Contact object - this means there is no Username field on that Object. Depending on how you set up your users, I would assume that the Email field is actually used for generating usernames for customers. In this case, you can just change {!Receiving_User.Username} to {!Receiving_User.Email} and this would be merged with the user's username.

If that is not working, what you might do is use a visualforce template with an apex:component, supply the {!Receiving_User.Id} to the component's controller, query for the User with that ContactId and then return this User.Username to the VF-Email.

2
  • Thanks for your replay. i cant use email instead of username. in visualforce template merge fields like Receiving_User.sending_user wont work
    – hareesh
    Sep 12, 2014 at 7:00
  • I'm not quite sure what you mean with Receiving_User.sending_user, but in VF-Templates you can leverage apex and thus you can query for more information.
    – 0ff
    Sep 12, 2014 at 9:54
0

You're using Communities (based on your comments), the field that you're referencing was used in previous iterations (see "Username" at https://help.salesforce.com/HTViewHelpDoc?id=contacts_fields.htm&language=en_US).

Your best bet is to do a minor extension and do a look up of the user based on the contact ID. The User record should have the contact Id linked.

select id, userName from User where contactId = :objectVar.id

You can see more information on how to use standard controllers here: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_pages_standardcontroller.htm. It gives you an example of how to create an sObject record for the standard controller passed (which is what I'm calling "objectVar" in the SOQL query above.

0

I had the same problem, but I solved it by putting all the text as a link by clicking the transform into link button

image

You must log in to answer this question.

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