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
Brandon (Penrod)Brandon (Penrod) 

DMLException Workaround

Goal: On custom object A insert create a Queue and create a separate custom object B that references the Queue we make.

Issue: To avoid the DML Exception the Queue has to be created using a @future method. This creates another issue where the @future code is being called after any of the source trigger and the following processes/flows that result from custom object A being inserted. The processes and flows need to execute after the Queue is created so we can access the Queue's values.

Has anyone else ran into this issue or possibly point me in the right direction?
Best Answer chosen by Brandon (Penrod)
KevinPKevinP
two ides here:

1. create a custom rest api endpoint that generates the queue for you. This will be executed synchronously -- your code will wait for the rest call to return. Then assign object b to it.

2: Insert the queue, and then schedule a batch job to execute in 30 seconds to update the record. <-- not high volume safe!

All Answers

KevinPKevinP
two ides here:

1. create a custom rest api endpoint that generates the queue for you. This will be executed synchronously -- your code will wait for the rest call to return. Then assign object b to it.

2: Insert the queue, and then schedule a batch job to execute in 30 seconds to update the record. <-- not high volume safe!
This was selected as the best answer
Brandon (Penrod)Brandon (Penrod)
Hello Kevin,

Thanks for the answer, we ended up implementing the scheduled job before you posted didn't get back to this. Since these queue additions aren't high volume we should be good to go.

Brandon