Apex テストクラスコミュニティユーザ作成

in #side7apex3 years ago
Id p = [select id from profile where name='Partner Community User'].id;
       
Account ac = new Account(name ='Grazitti') ;
insert ac; 

Contact con = new Contact(LastName ='testCon',AccountId = ac.Id);
insert con;  
          
User user = new User(alias = 'test123', email='[email protected]',
        emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
        localesidkey='en_US', profileid = p, country='United States',IsActive =true,
        ContactId = con.Id,
        timezonesidkey='America/Los_Angeles', username='[email protected]');

insert user;
system.runAs(user) {
    // statements to be executed by this test user.
}

https://www.forcetalks.com/salesforce-topic/can-we-insert-the-accountid-in-community-user/

Coin Marketplace

STEEM 0.19
TRX 0.14
JST 0.029
BTC 64337.17
ETH 3175.09
USDT 1.00
SBD 2.56