function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dkorba2k5dkorba2k5 

Customer Portal User Context

when logging in as a customer portal user to check what we have set-up with VF/Apex, I need to have the Apex queries execute based on the portal user, not as my profile.  But it seems that the userinfo.getuserid() function is still acting with my id.  Is there anyway to get around this?  To have it use the context of the user I'm logged in as in the portal instead of my id?
visualforce_devvisualforce_dev
Even i have userinfo.getuserid() function in queries . It works fine for my customer portal users and fetching the correct record, can u explain the exact problem.
dkorba2k5dkorba2k5
Yes you are correct IF I log in thru the portal as that user then the queries using UserInfo().getUserId work fine.  It's when I am logged in as me (Administrator) and then go to the portal user and hit the button to login as them that the function returns the context information for me, not the user I'm logged in as.  That's the issue I'm having which makes it hard to test scenario's for different users if I'm having to login directly thru the portal as them.  Make sense?
visualforce_devvisualforce_dev
I tested that also. as an admin i clicked on 'login as portal user'. The query in apexclass is fetching the record for contact only not for the admin.
dkorba2k5dkorba2k5
ugh .. nevermind.  going blind looking at code.  The query had a wrong parameter.  Thanks.
mehta.sagarmehta.sagar

Hi,

I m having the same problem with UserInfo.getUserId(). It is not picking the portals users UserId, in fact it is picking up the admin users UserId. Here admin means the person who had logged in through force.com.