Skip to main content

#MIXED_DML_OPERATION0 debatiendo

 "Advanced Flow Architecture: Delete Community-Linked Accounts via Queueable Apex Without Mixed DML Errors" 

📢 What to say in the post: 

 Just wrapped up a technical solution for safely deleting Salesforce Accounts related to Community Users—without hitting Mixed DML Operation errors! Using a combination of Screen Flow, Apex Invocable Methods, and Queueable classes, this approach ensures compliance with platform limitations while keeping things clean and automated. 

 👇 Dive into the full walkthrough and code breakdown!

 

https://medium.com/p/salesforce-flow-another-way-to-delete-account-related-to-community-user-via-queueable-apex-with-546fc1515cb6?source=social.linkedin&_nonce=GJUyASxC

 

#Flow  #MIXED_DML_OPERATION  #Que

0/9000

Hi Developers,

 

I found that if we could have a method in DescribeSObjectResult(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject_describe.htm) Class to identify if an object is setup object or non-setup object, then it will help us if we are doing DML on sobjects list or multiple objects in a single transaction.

 

If you think that this Idea is good, then up-vote :) !!

Apex method to identify that object is setup object or non-setup object ?

0/9000

I have created a flow to help me with creating community users from contact records because I didn't like exposing the new user form to my users, especially because specific profiles need to be chosen. Anyway, the flow basically takes details from Contact record and sets up a user, but before the user is created they are presented a screen that shows them the user that is about to be created...so that they can make any last minute changes....fix name spelling, add title, update email etc. When they click finish the user record is created and if any changes were made in that screen then the contact gets updated too. All of that works great, but there was one challenge... 

 

There is a thing called mixed dml operations that the platform won't let you do. Basically you can't create a user and update a contact in the same transaction. So, to get around this I sent the updated contact to a sub-flow that has a wait element before the contact update. The wait element solves that mixed dml problem, but introduces another. The wait element drops you into a page that says 'The flow interview is waiting. It will resume in the background when an event occurs.' And it just leaves you there. The contact gets updated, but it never takes you off that page.  So, I'm guessing it's because this is an autolaunched flow and not executing in the context of the visualforce page that the flow that called it was executing in. Therefore, it has no retURL.  This documentation seems to say that I can't set a retURL in an autolaunched flow. https://help.salesforce.com/articleView?id=vpm_url_set_retURL.htm&language=en_US&type=0

 

How can I can redirect back to something, anything? Ideally the contact that the flow started from, or just the recent contacts related list. 

3 comentarios
0/9000

When DML operations on certain sObjects sometimes referred to as setup objects (such as a User Object), along with, on the non-setup object (such as Accounts), in the same transaction, then, a Mixed DML error is thrown at a User.

 

This article will show you how to use Process Builder to avoid getting a Mixed DML Operation Error.

 

First, I will perform DML operation on Setup (User) and non-Setup (a Custom Object called Leave Balance) Objects in the same transaction.  This will generate a Mixed DML Operation error because one cannot perform a DML operation on Setup and non-Setup objects in the same transaction.

 

Next, I will show you how to use Time-dependent/Scheduled Action, in the Process Builder, to perform DML operations on Setup and non-Setup Objects in the same Process without incurring a Mixed DML operation error. The time-dependent/scheduled action is used because it helps in separating DML operations on Setup and non-Setup objects.

[New Post] Getting Started with Process Builder – Part 64 (How to fix MIXED_DML_OPERATION error )

1 comentario
0/9000