0

In some cases we need to change the owner of an invoice:

List<c2g__codaInvoice__c> linv = [SELECT id, OwnerId, c2g__OwnerCompany__c FROM c2g__codaInvoice__c WHERE id = 'a0z6F000008h3xfQAA'];
if (linv.size() > 0) {
    c2g__codaInvoice__c iv = linv[0];
    iv.OwnerId = '00G90000000zhIZ';
    iv.c2g__OwnerCompany__c = 'a0V90000000KW2uEAG';
    update iv;
}

If above code is executed in dev console, I get error message "FIELD_CUSTOM_VALIDATION_EXCEPTION, The company or owner cannot be changed".

Is there a way to change owner and company of an existing invoice?

1
  • Looks like this is a Custom Validation Rule created by FinancialForce themselves. Because it's a managed package, I'd expect you'd need to contact them to disable that rule.
    – Dan Jones
    Aug 9, 2016 at 10:56

1 Answer 1

1

Once the Owner is set on an Invoice, you can't change it (Triggers are in place to prevent it). If you've created an invoice in the wrong company, I'd suggest you discard it and start again. If it's something you want to do regularly, I'm afraid you're out of luck.

You must log in to answer this question.

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