You need to sign in to do that
Don't have an account?
sihmeieos
Get UserInformation on Customer Portal
Hello,
I'm trying to get user information(customer portal user= contact) in Apex class and trigger.
but I don't know how to get customer portal user infomation on Apex.
I want to add accountId to customObjectA when customObjectA created by custom portal user.
trigger instAccount on ProductNS__c (before insert) {
ProductNS__c[] pns = Trigger.new;
putAccountData.addDeleverCustomer(a)}
}
public with sharing class putAccountData {
public static void addDeleverCustomer(CustomObj A){
ID uid = UserID;//I get logined user's userId,contactId,accountId, here.
If (A.AccountId == null){
ID cid = [select ContactId from User where Id = uid];
ID aid = [select AccountId from Contact where Id = cid];
A.AccountId = aid;
}
}
}
Please help, how to get userId.
Thank you.
sihmeieos
You can use the UserInfo class in Visualforce page controllers:
ID uid = UserInfo.getUserId();
Cheers
All Answers
You can use the UserInfo class in Visualforce page controllers:
ID uid = UserInfo.getUserId();
Cheers
Thanks for quick response.
I confirm "Apex Code Develper's Guide",and edit below.
Thank you.
sihmeieos