1

If a user login to the customer portal,if he tries to raise a case, in case edit page the account and contact lookup fields are there how we get account and contact values automatically by user clicking the new case button?

2
  • Are these the account and contact details that relate to that customer user?
    – Dave Humm
    Commented Nov 7, 2016 at 14:44
  • yes From Salesforce users list take one Customer portal user in users detail page we find related contact by clicking that contact it will display contacts details page in that page we find account lookup field.finally we want that both account and contact values by that user logins to the customer portal.
    – chandra
    Commented Nov 7, 2016 at 14:58

1 Answer 1

3

You can query the related Contact using ContactId, and query related Contact details using Contact.SomeField__c. Similarly, you can query the related Account using Contact.AccountId.

SELECT
    Username,
    ContactId, Contact.Name,
    Contact.AccountId, Contact.Account.Name
FROM User
WHERE Id = 'community_user_id'

If the user in question is the running user, simply change the WHERE clause to:

WHERE Id = :UserInfo.getUserId()
5
  • Could you also use id = UserInfo.getUserId() instead of id= 'community user'?
    – abhi
    Commented Nov 7, 2016 at 15:35
  • Absolutely for code run as that user.
    – Adrian Larson
    Commented Nov 7, 2016 at 15:35
  • here id ='community_user_id' place can i pass like this id='High volume customer portal user' (or) user id value i will pass,if i pass the user id it will be static i want dynamic
    – chandra
    Commented Nov 7, 2016 at 15:36
  • @chandra are you trying to get this data when the community user is the running user?
    – Adrian Larson
    Commented Nov 7, 2016 at 15:37
  • 2
    @chandra you do realize that community_user_id is just a place holder in the query. You need to pass the actual user id.
    – abhi
    Commented Nov 7, 2016 at 15:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .