function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
/** * ポータルユーザ */ public static User createPortalUser(Profile profile, Contact contact, Boolean isInsert) { User portalUser = new User( LastName = 'TestPortalUser' ,Alias = 'Portal' ,Email = 'portaluser@example.com' ,Username = 'portaluser@example.com.dev' ,CommunityNickname = 'TestPortalUser' ,EmailEncodingKey = 'ISO-2022-JP' ,TimeZoneSidKey = 'Asia/Tokyo' ,LocaleSidKey = 'ja_JP' ,LanguageLocaleKey = 'ja' ,ProfileId = profile.Id ,ContactId = contact.Id ); if (isInsert) { insert portalUser; } return portalUser; }
/** * カスタマーポータル */ static testMethod void createPortalUserTest() { System.runAs(testAdminUser) { Account account = CommonTester.createAccount(true); Contact contact = CommonTester.createContact(account, true); Profile profaile = CommonDao.getProfile(System.Label.Profile_Portal_User); Test.startTest(); // Insertなし User portalUser = CommonTester.createPortalUser(profaile, contact, false); System.assertEquals(String.isEmpty(portalUser.Id), true); // Insertあり portalUser = CommonTester.createPortalUser(profaile, contact, true); System.assertEquals(String.isNotEmpty(portalUser.Id), true); Test.stopTest(); } }
以前ポータルユーザだったときはこんな感じでApexから登録できました。 呼び出し時のイメージです。
上記はテストクラスで使用するためのテストユーザを用意するための処理ですが、同じような感じで値をセットすれば登録処理を実装できると思います。