You need to sign in to do that
Don't have an account?

Getting contact through portal user not working
Hi all,
In our customer portal we have users created through "Enable Customer Users" option in contact. While saving user unfortunately I am getting an exception from our trigger that contact Id is null. I am facing this issue while creating user through contact. I guess something went wrong in latest release?
Any suggestions please?
In our customer portal we have users created through "Enable Customer Users" option in contact. While saving user unfortunately I am getting an exception from our trigger that contact Id is null. I am facing this issue while creating user through contact. I guess something went wrong in latest release?
Any suggestions please?
When you click on manage external user on any contact and select "Enable Customer user", then you are redirected to user creation page autometically then you select Customer Community in Licence picklist and "Customer community user" in profile picklist. Correct?
Do you get this error when you click on Save button on User Creation page?
and Please confirm if you have written any tirgger on user object?
Regards,
Sameer Tyagi
http://mirketa.com/
I am getting error when I click on save button of the user with customer community user license.
I have trigger on user object which is getting the contact Id before insert. The contact Id is getting null and throwing null pointer exception?
Any suggestoins please?
So its clear that issue with your trigger code. Can you please share sample code of your trigger. so that I can provide you solution quickly.
Sameer
trigger EmailChangeNotification on User (after Update, before insert,before update) {
String userid,profileName,profileId,contactid;
if(trigger.isBefore){
for(User u2 : trigger.new){
contactid = u2.ContactId;
/*I am getting contactId as null here...any reason why?
}
}
}
I have checked your trigger, which is working fine. It does not show any error during customer user creation and showing the contactid in debug log also.
I pasted same code which you sent me.
Sameer
Sameer
Also can you confirm that you are getting contactID before insert?
My org is recently updated with winter 15..may be that could be the problem?
Thanks for you help indeed..
and my developer org also updated with winter 15. Thats not the issue.
Issue with Code . I am damn sure.
Sameer
if(Trigger.IsBefore){
Integer i=0;
String userid,profileName,profileId,contactid;
User u;
Contact portalUser;
for(User u2 : trigger.new){
system.debug('===========u2 =========='+u2);
userid = Trigger.isUpdate ? u2.Id : null;
profileId = u2.ProfileId;
contactid = u2.ContactId;
}
system.debug('===========contactid =========='+contactid); //Getting Null here
try{
if(Trigger.isInsert && contactid != null)
portalUser = [Select Account.Member_Type__c, Account.recordType.name from Contact where Id =:contactid LIMIT 1];
}catch(Exception e){}
for(User u1 : trigger.new){
if(Trigger.isInsert){
if(!Test.isRunningTest()){
System.debug('=======portalUser======'+portalUser);
if(portalUser.Account.recordType.name == 'Member'){
if((portalUser.Account.Member_Type__c == 'A') && !(profileName == 'A Member Checker' || profileName == 'A Member Editor')){
//Some Contion
}
}
}
}
}
}
instead of this "if(trigger.isBefore){" try putting this "if(trigger.isBefore && trigger.isInsert) {"
Check if any other trigger is updating the User record(It is just a guess).
Regards,
Manjunath C S
Requesting you for the whole code from line one. So that I will be able to know where your bracket is closed and where is start of bracket.
Sameer
Error Message : Apex trigger EmailChangeNotification caused an unexpected exception, contact your administrator: EmailChangeNotification: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.EmailChangeNotification: line 26, column 1
Full Code
trigger EmailChangeNotification on User (after Update, before insert,before update) {
if(Trigger.IsBefore){
Integer i=0;
String userid,profileName,profileId,contactid;
User u;
Contact portalUser;
for(User u2 : trigger.new){
system.debug('===========u2 =========='+u2);
userid = Trigger.isUpdate ? u2.Id : null;
profileId = u2.ProfileId;
contactid = u2.ContactId;
}
system.debug('===========contactid =========='+contactid); //Getting Null here
try{
if(Trigger.isInsert && contactid != null)
portalUser = [Select Account.Member_Type__c, Account.recordType.name from Contact where Id =:contactid LIMIT 1];
}catch(Exception e){}
for(User u1 : trigger.new){
if(Trigger.isInsert){
if(!Test.isRunningTest()){
System.debug('=======portalUser======'+portalUser);
if(portalUser.Account.recordType.name == 'Member'){
if((portalUser.Account.Member_Type__c == 'A') && !(profileName == 'A Member Checker' || profileName == 'A Member Editor')){
//Some Contion
}
}
}
}
}
}
}
I do not see any error with your code, working fine.
here is the debug.
I am doing it like this.
then redirected to User creation screen on click of Enable Customer User.
Now you are getting error on click on save. am I correct?
Sameer
Its sring 15My org is updated to spring 15 already and ap1 is still not updated to spring 15 I guess...
Sorry I could not fix your issue.
I will try this same code when my org will be updated with Spring 15
Sameer Tyagi
However thanks for your great support.