You need to sign in to do that
Don't have an account?
Gallery Integration
Process builder hitting SOQL queries:101 error
Hi Everyone,
I am trying to add 100++ campaign members to the campaign that I have created.
However while doing this we encounter a SOQL queries:101 error.
After doing some checking this error is caused by this 3 process builders:
1. Process builder to update a campaign member field based on contact field whenever it is created.
2. Process builder to update a campaign member field based on other campaign member field whenever it is created.
3. Process builder to update campaign member field based on other campaign field whenever it is created or edited.
If the we limit the upload to 25 or 50 members at once we will not receive this error.
After deactivating these 3 process builder the upload can work correctly even with 100++ member at once
Are there any solution to solve this? Does process builder do not support bulkified upload?
I am trying to add 100++ campaign members to the campaign that I have created.
However while doing this we encounter a SOQL queries:101 error.
After doing some checking this error is caused by this 3 process builders:
1. Process builder to update a campaign member field based on contact field whenever it is created.
2. Process builder to update a campaign member field based on other campaign member field whenever it is created.
3. Process builder to update campaign member field based on other campaign field whenever it is created or edited.
If the we limit the upload to 25 or 50 members at once we will not receive this error.
After deactivating these 3 process builder the upload can work correctly even with 100++ member at once
Are there any solution to solve this? Does process builder do not support bulkified upload?
First create a class named 'checkRecursive' and copy the following code in it:
Now create a trigger on Campaign member and copy this code in your trigger: Note: There might be few compilation errors(typos).
Let me know if it helps.
Thanks!
All Answers
Can you please tell me what value you are assigning to Relationship Manager. The field under 'Value' is only partially visible.
Its the field from contacts object associated with this campaign member called "Relation_Manager__c" too. It is a picklist field.
First create a class named 'checkRecursive' and copy the following code in it:
Now create a trigger on Campaign member and copy this code in your trigger: Note: There might be few compilation errors(typos).
Let me know if it helps.
Thanks!
Thanks for this! Really appreciate your help.
However, this is just one of the process builder that caused the error.
Does this means that I must create another 2 trigger to cover the other process builder?
Thanks!
No, not at all. We can append the logic for the other two Processes. How can that be done will depend on what logic the other two processes executing.
If you found my answer helpful, please mark it as the best answer so that others with similar kind of problem can benefit from this post.
Thanks
Really appreciate for your help.
I am new in Apex and just start learning.
As i read in some article it said that i's better to use "click and drag" process like workflow rule and process builder rather than Apex code, because Apex required more effort and also time for the deployment.
However, if process builder could not provide what we need then I believe we don't have other choices.
This is the second and third process builders, could these fit into 1 trigger or shall we create another triggers for them?
2nd Process Builder
3rd Process Builder
Also, in addition to the code that you write before for the 1st process builder.
Whats the checkRecursive function for?
I tried another similar code like this, and it also work.
Shall this code be replaced?
The code you provided will also work. It just skipped my mind that we could do all this on before event as well.
The purpose of checkrecursive class was to skip the recursion because the trigger was working on After update event(Let me know if the point is still not clear to you).
And about the article which you read, it is absolutely correct. Apex code should be your last resort. Because coding comes with a lot of considerations which programmers often miss which leads to unhandled exceptions.
But why use code in this scenario?
The answer is because you are hitting the governer limits.
So you have two options now: Either use a flow(I haven't worked much with flows) or use the apex trigger.
And for the snaps you sent me, yes we can add that functionality in your trigger code. No need to create seperate triggers for them.
It is always recommended that you use a single trigger per object(Best Practice).
Thanks a lot for your clarification.
Since the before event code is simpler, I will use that as it has the same functionality.
Will try to create another 2 triggers, I think it's best to separate trigger for the 3rd one because it associated with campaign object, not campaign member.
The trigger is succesfully created, and I successfully inserted 200 campaign member at once.
However, when I create the Test Class the same 101 soql queries occured again.
Is there anything wrong with my test class?
The reason you are getting this error is because you are doing a SOQL query in your for loop.
Try this code:
Thanks for this.
I manage to take out the query from the loop.