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
DCSDCS 

Community Nickname of user object

I am writing a test method in which I am inserting a user.  When I try to set a value for the CommunityNickname

field, it gives a compilation error message as follows

 


Save error: Invalid field communityNickname for SObject User 

 

Is this field not accessible?  

 

WesNolte__cWesNolte__c

Hey

 

Is the nickname you're creating in the form of an email address?

 

Cheers,

Wes

DCSDCS

No. it is not email address format. I am trying to put a short form of first name or last name. No special characters.
The issue is not with the value format. The field itself is not accessible

WesNolte__cWesNolte__c

Oh. Well that's strange becuase this works,

 

User user = new User();
            user.Username = 'test1@2auk.com';
            user.LastName = 'LastTestName';
            user.Email = 'test@2auk.com';
            user.alias = 'testAl';
user.communitynickname = 'test user';
            user.TimeZoneSidKey = 'America/New_York';
            user.LocaleSidKey = 'en_US';
            user.EmailEncodingKey = 'ISO-8859-1';
            user.ProfileId = [select id from Profile where Name='System Administrator'].Id;
            user.LanguageLocaleKey = 'en_US';
            insert user;

 

Wes

duggladuggla

Is this just a case-sensitivity problem?

 

user.communitynickname works but user.communityNickname does not?