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
Anuj Thakur 4Anuj Thakur 4 

is it possible to create grand child record using process builder

1.we can create child record using process builder but is it possible to  create grand child record using process builder?
2. System.enqueueJob() is getting called from Batch class execute method and one more System.enqueueJob() is calling from trigger in same transaction then we get the error that multiple queueable not allowed in one transaction. But You can add up to 50 jobs to the queue with System.enqueueJob in a single transaction then why we get the error.
Any response is appriciated!!


Lokesh KumarLokesh Kumar
You have two things going on here:
You can only execute one job from a job.
Triggers fire in chunks of 200 records.
So if you update 201 records, you will have one Queueable kicked off with 200 records, and another kicked off with just one record. As soon as you execute a second job, you're going to error out. The simple fix is to keep your batch size low enough that you know evs will contain fewer than 200 records. A more robust fix is to add some logic to check if you should execute synchronously or asynhronously, and only use Queueable in the latter case.


Salesforce says you can add 50 jobs to the queue per transaction. But what Salesforce doesn't mention clearly is that it is not applicable for batch, you can only enqueue one job. Even if you enqueue your job in the trigger, you are still in a batch context.
Make sure you don't call enqueueJob twice at any point in the same transaction. For example an insert that would call an update and would execute enqueueJob twice.
Make sure you don't have enqueueJob in a for loop.
Make sure your code is bulkify.
Lokesh KumarLokesh Kumar
NO Using process builder grandchild cannot be created. 
Anuj Thakur 4Anuj Thakur 4
Thanks Lokesh for clarifying the doubts.
So for first thing, you mean to say we can call two Enqueuejob in one transaction?