2

I am trying to insert a invoice record from apex code but getting the error "DML operation Insert not allowed on Invoice" . I am not sure is it some issue on permission level or salesforce does not allow it . This is a sample code i am trying.Please help me if I am missing anything.

invoice inv = new invoice();
insert inv;

Update : I am getting the below error now => |System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Can't create Invoice in Apex. Use REST API instead.: []

1 Answer 1

2

This object is indeed not insertable via apex dml operations, you may notice it from Supported Calls from Invoice SOAP API Documentation

Supported Calls

describeLayout(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), search(), update()

as you can see, it it missing create() which is present for Contact, for example:

Supported Calls

create(), delete(), describeLayout(), describeSObjects(), getDeleted(), getUpdated(), merge(), query(), retrieve(), search(), undelete(), update(), upsert()

It is not a permission level problem. It is not possible to create Invoice record in apex via DML.

You must log in to answer this question.

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