I'm getting this weird exception during test class. The test class is related to Contract object, and I'm almost sure that nothing was changed lately regarding. Also I searched my whole code, to find from were this error message come from, but couldn't find it.. Search in all apex code, triggers, validation rule, field lookup filters, custom labels.. + There is no approval process for the contract object and we didn't enable at all the apex record locking/unlocking, therefore I don't know what can lock the record...

Any other idea? Possible this is internal issue in SF?

 testClsObjectCreator clsObjectCreator = new testClsObjectCreator();
    Account acc = clsObjectCreator.createAccount();
    Product_Family__c pf = clsObjectCreator.CreateProductFamily();
    Product2 prod = clsObjectCreator.CreateProduct2(pf.Id, 'test123');
    Registration__c reg = clsObjectCreator.CreateRegistration(prod, 'Module');
    Contract contract = clsObjectCreator.CreateSupportContract(acc, reg); 
    contract.Status = 'Activated';


    update contract;
    catch(Exception e){
        System.debug('####' + e.getStackTraceString());
         System.debug('####' + e);

System.DmlException: Update failed. First exception on row 0 with id 800L0000000VbUWIA0; first error: ENTITY_IS_LOCKED, An activated support contract's account can't be changed.: [AccountId]

  • Do you have any trigger that set AccountId on the Contract object?
    – Adrian Larson
    Nov 13, 2016 at 14:31
  • Yes. I do. But why should it cause the error?
    – Liron C
    Nov 13, 2016 at 15:00
  • Thanks.Indeed this is the issue. Now I'll try to find out why suddenly this error appear. As this logic wasn't added/changed in my trigger or test lately. Thanks, again
    – Liron C
    Nov 13, 2016 at 15:12

1 Answer 1


Another member on our forum has experienced this issue as well. In summary, you cannot change the lookup to Account on any Contract record where the Status is set to 'Activated'. The reason you are seeing this error is likely that a trigger on Contract is trying to change the lookup without first checking for that Status.

Why are you seeing this error now when you didn't change the relevant logic recently? It's hard to say without seeing the trigger itself, but likely it's because a workflow or trigger was updated elsewhere that caused your data to meet the criteria required to change the AccountId, or activated the Contract before reparenting.

  • 1
    I found what changed in the code... The code check when the status is changed to 'Activated' and then setup the accountId - this work well until lately. But now it failed, as other process after the trigger, update the contract again, therefore this trigger run twice, and it fail in the second run. I changed the trigger to run only at the first run.
    – Liron C
    Nov 13, 2016 at 16:17

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