포털 사용자와 포털에 할당 된 두 개의 프로필이 있습니다. 일부 조건이 충족 될 때마다 프로필을 변경하기 위해 트리거를 실행하고 싶습니다.Apex를 사용하여 Salesforce에서 고객 포털 사용자 프로필 변경
이것이 가능합니까?
포털 사용자와 포털에 할당 된 두 개의 프로필이 있습니다. 일부 조건이 충족 될 때마다 프로필을 변경하기 위해 트리거를 실행하고 싶습니다.Apex를 사용하여 Salesforce에서 고객 포털 사용자 프로필 변경
이것이 가능합니까?
예. 프로필 개체 자체에 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());
}
System.runAs (U) 만 테스트 클래스에서 사용을, 에이 클래스에 대한 당신은 쓸 수 없습니다 위 코드