I want to capture the default mail id for Ex "Support@support.com" on E-mail field on Contact, while making the contact as Portal user? How to pre populate the Emailid ?
Can somebodys suggest/help?
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
I want to capture the default mail id for Ex "Support@support.com" on E-mail field on Contact, while making the contact as Portal user? How to pre populate the Emailid ?
Can somebodys suggest/help?
Probably you can create a trigger on Users object.
The trigger should fire when the profile is Portal User and set email as you want.
All Answers
Probably you can create a trigger on Users object.
The trigger should fire when the profile is Portal User and set email as you want.
Hi,
I have created trigger on User object, but it is not working, i am writing Trigger for the First time, can you please help me out on this.
Below is the trigger which i wrote, let me know if its wrong.
trigger getEmailOnPortalUserCreation on User(before insert, before update) {
String typeOfUser='';
for (User u : [SELECT Id, UserType, ContactId From User]){
System.debug('User Type is ' + u.UserType);
typeOfUser = u.userType;
}
for(User u:Trigger.new)
//for case created by portal users only, get the userType to check for Portal user
if(typeOfUser == 'CSPLitePortal'){
u.Email = 'AgentSupport@support.com';
}
}
You can try this : (I am not sure what is the field on your user record that shows this is a portal use)
trigger getEmailOnPortalUserCreation on User(before insert, before update) {
String typeOfUser='';
for(User u:Trigger.new)
if(u.typeOfUser == 'CSPLitePortal'){
u.Email = 'AgentSupport@support.com';
}
}
Hi,
It is still not working for me. I did not get any compilation errors. When i create a portal user, Email id is not getting updated.
Is there anything that we can do ?we have just written Apex Trigger, will it be sufficient or it required any other ?
Hi,
I have created new trigger, can you please let me know what is missing for this Trigger?
trigger SetEmailIdOnPortalUserCreation on User(after insert) {
List<User> portalUsers = [Select Id, Email from User where Id IN :Trigger.new and UserType = 'CSPLitePortal' and Profile.Name='Overage High Volume Customer Portal User'];
for(User u : portalUsers){
u.Email = 'LiveGuideSupport@jci.com';
}
update portalUsers;
}
Please try this and let me know the out put :
trigger SetEmailIdOnPortalUserCreation on User(after insert) {
List<User> portalUsers = [Select Id, Email from User where Id IN :Trigger.new and UserType = 'CSPLitePortal' and Profile.Name='Overage High Volume Customer Portal User'];
List<user> lstUsr = new List<User>();
for(User u : portalUsers){
u.Email = 'LiveGuideSupport@jci.com';
lstUsr.add(u);
}
update lstUsr;
}
Hello,
I checked with updated Trigger, but still email is not getting updated to default value as "LiveGuideSupport@jci.com" ?
I really do not have any idea, why salesforce is not updating the records, does Salesforce doesn't allow us to update the Email id on User Edit Screen
( when Contact Enable as portal user, user edit screen displays)
Have you checked the email inbox for any confirmation if you are getting eny. Usually when you change user's email address the email address does not change right away. You have to confirm that new email address.
Please check if you are getting any email messages to confirm the email.