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

Apex code not working
Hi All I am looking to get the contact that is associated with the user who logged in and redirect to the detail page. But it is not throwing any error but I am not able to redirect properly can some one help where the code is wrong?
public class MyContact {
public PageReference redirect() {
User u=[Select contactid from User where id=:UserInfo.getUserId()];
system.debug(u);
system.debug(u.contactid);
PageReference pageRef = new PageReference('/' + 'u.contactid');
pageref.setredirect(True);
return pageref;
}
public MyContact(){}
}
public class MyContact {
public PageReference redirect() {
User u=[Select contactid from User where id=:UserInfo.getUserId()];
system.debug(u);
system.debug(u.contactid);
PageReference pageRef = new PageReference('/' + 'u.contactid');
pageref.setredirect(True);
return pageref;
}
public MyContact(){}
}
PageReference pageRef = new PageReference('/' + 'u.contactid');
Should not put u.contactid inside single quote, that would just give you the string iteself not the id value.