this is the structure of my code:

In the constructor i build a fake account which i use into a visualforce page to get an inputfield which can lookup into accounts through the OwnerId.

userInput = new Account();

Then i have a method which tries to fetch account teams using the OwnerId previously set.

String rolestring = 'Core User';

AccountTeamMember[] clients = [Select UserId, AccountId, TeamMemberRole From AccountTeamMember Where UserId = :userInput.OwnerId AND TeamMemberRole = :rolestring];

This simply isn't working. I tried the very same query through the developer console (and it works fine) but even by putting a fixed 15-digits ID for the userId, it's not working. Then i tried with the same ID but with its 18-digit version and it WORKS. So the question is: how can i get the 18-digit version of the id i previously put in the OwnerId field of my 'fake' account? I also tried to fetch the user and assign its ID to an ID variable but it's still not working ! (i found this post saying it would do the trick but it doesn't !) I am basically looking for something like the CASESAFEID function but for Apex!

  • 1
    The answer you linked is the correct method. There's something else wrong in your code. – sfdcfox Apr 14 '16 at 21:14
  • 1
    I guess the ownerId for you is null .Put debug logs and figure whats wrong – Mohith Shrivastava Apr 14 '16 at 21:17
  • OwnerId is not null, i tried to fetch the user using that id and it works. – Marco Dagrada Apr 14 '16 at 21:22

I was looking for partner users and i had another user with the same name of the one i was testing with. It seems no partner users can be shown in the inputfield lookups.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.