When i am writing test class for Commerce Cloud. Then Account is necessary is buyer account. How i can enable Acount.IsBuyer field to true in test class. In UI i can enable as buyer account by click on button "Enable Buyer Account".

As isBuyer is not writable in Apex Code.

1 Answer 1


Can you try below code and see if it works

BuyerAccount buyerAccount = new BuyerAccount();
buyerAccount.BuyerId = account.Id;
buyerAccount.Name = 'Test Buyer Account (BA-AJ)';
buyerAccount.IsActive = true;
insert buyerAccount;
  • Thank you @swetha. Commented Dec 26, 2020 at 16:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .