Loading
Salesforce から送信されるメールは、承認済ドメインからのみとなります続きを読む

ChatterAnswersCreateAccountTest クラスにてエラーが発生する

公開日: Jan 24, 2025
説明
[テストを実行] もしくは [すべてのテストを実行] を実施した際に ChatterAnswersCreateAccountTest クラスにて下記エラーが発生する場合があります。
 
  エラーメッセージ
  --------------
  System.DmlException: Insert failed. First exception on row 0; first error: INACTIVE_OWNER_OR_USER, operation performed with inactive user: []
  --------------
 
 * ChatterAnswersCreateAccountTest クラスは、Chatter アンサーを有効にした際に Salesforce が自動で作成するテストクラスです。
解決策
ChatterAnswersCreateAccountTest テストクラスに問題があったためエラーが発生します。Summer'13 以前のリリースで有効にしており、本エラーが発生した場合には以下の対処を行って下さい。

   - Sandbox 環境の場合
     ChatterAnswersCreateAccountTest を後述する内容に変更して下さい。

   - 本番環境の場合
      1. ChatterAnswersCreateAccountTest を後述する内容に変更してください。

     2. 変更が完了したら ChatterAnswersCreateAccountTest クラスのデプロイを行います。
 
ChatterAnswersCreateAccountTest
------------------------------ 
@isTest
private class ChatterAnswersCreateAccountTest {
    static testMethod void validateAccountCreation() {
        Profile[] p = [SELECT Id FROM Profile WHERE UserType = 'Standard'];
        User[] user = [SELECT Id, Firstname, Lastname FROM User WHERE IsActive = true and ProfileId =: p[0].Id];
        // We cannot create account without a user.
        if (user.size() == 0) { return; }
        String firstName = user[0].FirstName;
        String lastName = user[0].LastName;
        String userId = user[0].Id;
        String accountId = new ChatterAnswers().createAccount(firstName, lastName, userId);
        Account account = [SELECT name, ownerId from Account where Id =: accountId];
        System.assertEquals(firstName + ' ' + lastName, account.name);
        System.assertEquals(userId, account.ownerId);
    }
}
------------------------------ 
ナレッジ記事番号

000385949

 
読み込み中
Salesforce Help | Article