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
glynnoglynno 

How to write to custom object using Apex

I have an apex trigger that runs when a Chatter message is posted. I also have a custom object.  I would like to write text to the custom object from my apex trigger.  Everything works fine when an admin user posts a chatter.  However, when a non admin user posts a chatter I get an exception:

 

 

Apex trigger company.test caused an unexpected exception, contact your administrator: company.test: execution of BeforeUpdate

caused by: System.DmlException: Insert failed. First exception on row 0; first error: OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type: []: (company)

 

 

 

How do I get this to work for non admin users?

 

shra1_devshra1_dev

This is because of the create permissions on the custom object.

 

Provide create permissions on the custom object for all profiles of non-admin users.

 

Regards,

Shravan

pumbaapumbaa
I have chatter external users for our customer. Even I enable all fields for the object they are still not able to post a chatter post due to the insert exception. Please advise, Ricky