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
Anupama SamantroyAnupama Samantroy 

Creating custom object on User Creation: MIXED DML EXCEPTION

I have a requirement that on creation of Contact an User should be created and on successful creation of user another Custom Object is to be created.
For the first part I have created a future method to create the user but as I cannot call another future method or batch class from that method I am not able to create the custom object.
Any help is appreciated.

Thanks 
Anupama
Best Answer chosen by Anupama Samantroy
Anupama SamantroyAnupama Samantroy
I used the salesforce Queueable Apex to implement the same. It worked perfect :)

All Answers

ManojjenaManojjena
Hi Anupama.

Inside the same future method you can create both user and the custom object .

Check below link here the code is for same kind of problem .

https://developer.salesforce.com/forums/ForumsMain?id=906F0000000MH0kIAG

Let me know if still you are facing problem .
Thanks 
Manoj 
 
Anupama SamantroyAnupama Samantroy
Hi Manoj,

I am already creating the User on creation of Contact using a future method. Now again on user creation I want the custom object. So I cant call another future method from one future . Is there any other way?

Thanks
Anupama
Anupama SamantroyAnupama Samantroy
I used the salesforce Queueable Apex to implement the same. It worked perfect :)
This was selected as the best answer