New answers tagged


The variable should not be in quotes, as this makes it a String. When cast back to an Id, it is found to be invalid, thus causing the rrror.;


You need to use putSobject instead of put. The latter only works on normal fields, while the former is used to set relationship objects. con.putSObject('Account',a);


You can perform DML operations on more than one type of sObject in a single class using the following process: Create a method that performs a DML operation on one type of sObject. Create a second method that uses the future annotation to manipulate a second sObject type. DML operations on certain sObjects, sometimes referred to as setup objects, can’t be ...


This is a salesforce limitation and the solution is to keep the non setup object (Contact) in the synchronous call, move the setup object (User) in async call either with a future or queueable method. Refer the documentation for more details: SObjects That Cannot Be Used Together in DML Operations that also has an example. Article to avoid Mixed DML ...


I realize this is old but I kinda solved for this problem another way and wanted to share. We put the group ID on a custom object corresponding to which the group member inserts happen - kind of like a custom group object, if you will. So I decided to put the FOR UPDATE on the custom object query (although, we didn't really need the custom object records in ...

Top 50 recent answers are included