1

I have a test class block which I am unable to cover as it queries UserAccountTeamMember object for a default account team member. I tried to insert record in that object through test class but DML is not allowed in UserAccountTeamMember. Can anyone advise about how to cover that peice of code.

Code:

     visitReport = [Select Id,OwnerId from test2__c where Id=:visitReportObject.Id limit 5000];
   for(UserAccountTeamMember userObject: [SELECT UserId, OwnerId FROM UserAccountTeamMember WHERE OwnerId =: visitReport.OwnerId]){
                        ParticipantObject = new test3__c();
                        ParticipantObject.user__c = userObject.UserId;
                        ParticipantObject.test2__c = visitReport.Id;
                        ParticipantList.add(ParticipantObject);
                    }
0

I think I've found the answer to your issue with DML on the account team member. To insert an account team member, it seems that you also need to create an account share (depends on your code) and make certain you've created the account team member user properly that you're inserting.

There are two related posts on the subject that between them should provide you with what you need. I found this post which gives a bit of insight into the aforementioned issues. And I found this post: My test case is not detecting account team member? which has a trigger and code that inserts an account team member. Between the two of them, I think you should be all set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.