2011-11-09 3 views

답변

0

예. 프로필 개체 자체에 DML is forbidden 있지만, 당신은 (아펙스 개발자 가이드에서) 사용자의 프로파일을 변경할 수 있습니다

Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; 
User u = new User(Alias = 'standt', Email='[email protected]', 
    EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
    LocaleSidKey='en_US', ProfileId = p.Id, // <--- 
    TimeZoneSidKey='America/Los_Angeles', UserName='[email protected]'); 

System.runAs(u) 
{ 
    // The following code runs as user 'u' 
    System.debug('Current User: ' + UserInfo.getUserName()); 
    System.debug('Current Profile: ' + UserInfo.getProfileId()); 
} 
0

System.runAs (U) 만 테스트 클래스에서 사용을, 에이 클래스에 대한 당신은 쓸 수 없습니다 위 코드