function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tribulationstribulations 

DML operation INSERT not allowed

I'm getting System.TypeException: DML operation INSERT not allowed on on object that I have created.

The error occurs when running many of the tests with asUser with a profile of "Standard User".

The object  Deployment Status is In Development, and all of the fields are Editable except

CreatedBy, LastModifiedBy, formula fields, and Name which is of type Auto Number

I've had it working before but did a retreive, changed test code and deploy using ant.


I've had similar problem in the past when performing an UPDATE but managed to fix it.

None of the fields are required. Some fields are Lookups but those are not set and not required either.

There are no master-detail types.

 

 

 

 

Starz26Starz26

I do not believe the "Standard User" profile can see objects that are not deployed and thus when using runAs is why you are getting that error.

pujapuja

May be the Standard user profile don't have  the permission for this object.

You set the CRUD permission for that object via profile.

 

 

Thanks

 

tribulationstribulations
That was it. Doesn't make much since to me why that should be so for testing. Thanks.
praveen murugesanpraveen murugesan
I have faced the same issue.

Resolved by assining CRUD permission.

In your scenario Standard user profile may don't have the permission for this object.
You can add either permission via profile or assign permission set with requrired permissions.

Thanks.