Process Builder Error - Was working and now throwing up an issue, any ideas why? - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Scott WalkerScott Walker 

Process Builder Error - Was working and now throwing up an issue, any ideas why?

Hi all

Have this weird error.  I built a process builder which updates alookup field on a custom object called purchase_request__c  with a specific related id but for some reason its all of a sudden throwing up an error even though the process builder was working fine.  Any idea why the error shown below could be occuring?

Error Occurred During Flow "PRRU_000001date_Purchase_Request": The flow tried to update these records: nul...

Error element myRule_1_A1 (FlowRecordUpdate).
The flow tried to update these records: null. This error occurred: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: dlrs_Purchase_Request_FormTrigger: System.LimitException: dlrs:Too many SOQL queries: 101. For details, see API Exceptions.

This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.

Flow Details
Flow Name: PRRU_000001date_Purchase_Request
Type: Workflow
Version: 1
Status: Active

Flow Interview Details
Interview Label: PRRU_000001date_Purchase_Request-1_InterviewLabel
Current User: Aaron Louie (005G0000007BpTo)
Start time: 9/19/2017 12:42 PM
Duration: 1 seconds

How the Interview Started
Aaron Louie (005G0000007BpTo) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = null
myVariable_current = a4s0f000000XyTaAAK

ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "9/19/2017 12:42 PM"

DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!formula_myRule_1} (true) Equals true
Logic: All conditions must be true (AND)

RECORD UPDATE: myRule_1_A1
Find all Purchase_Request_Form__c records where:
Id Equals {!myVariable_current.Id} (a4s0f000000XyTaAAK)
Update the records’ field values.
Purchase_Request_Roll_Ups__c = a2D0f0000016gw2
Result
Failed to update records that meet the filter criteria.

Error Occurred: The flow tried to update these records: null. This error occurred: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: dlrs_Purchase_Request_FormTrigger: System.LimitException: dlrs:Too many SOQL queries: 101. For details, see API Exceptions.
Best Answer chosen by Scott Walker
Doug BurkhartDoug Burkhart
Happy to help you see this through.

I don't think the batch scheduling will work because it's not a matter of the updates running, it's an issue with them processing due to the number of records the rollup has to run back through on the back side.

As far as converting to M/D, that it not as difficult as it sounds. The first requirement is to ensure that every Purchase Request Record has a Purchase Request Rollup Record populated in the Lookup field. So, I would do the following:

1) Deactive the Declarative Rollup Summary
2) Create a new Purchase Request Rollup Record (This will be the Master for all of the archived records you don't want on the current record with ID = a2D0f0000016gw2)
3) Populate all previous Purchase Requests with the ID of the newly created Rollup record (mass update via data loader)
4) Confirm via reporting that all Purchase Requests have the Rollup Lookup field populated.
5) Edit lookup field to change field type to M/D
6) Create rollup summary fields on Rollup Record Object (Yes, you can use picklists to filter which records get rolled up)

Doug

All Answers

Naveen DhanarajNaveen Dhanaraj
The Problem is in your Trigger Named "dlrs_Purchase_Request_FormTrigger" Follow best practices to write Trigger.

1.Trigger and Bulk Request Best Practices-(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_bestpract.htm)
2.Apex Code Best Practices (https://developer.salesforce.com/page/Apex_Code_Best_Practices)
Doug BurkhartDoug Burkhart
Hi Scott,

Here's the main part of the error we need to focus on:
Too many SOQL queries: 101. For details, see API Exceptions.
The Process Builder, even when set up properly, can not handle processing large batches of records at the same time. So, while your Process works, it appears there is either and integration, data upload, or mass update occurring that is trying to trigger this Process multiple times at the same time.

Were you running and update, upload, or do you know what action was occurring that was trying to start this Process?

Doug
Scott WalkerScott Walker
Oh weird.  OK so the process builder is basically putting the same record ID into the lookup field so I can use a roll-up summary app on a rollup summary object (ratehr than the rpefered master-detail which I can'y use as the objects were made ages ago).  So far this program has made 65 lookups and thats it (in a coupld of days mind you)  The action that starts this process is the saving of the purcase request record.  Is there anythgn I can do?  All I need to do is ensure the lookup field has the follwing when a purchase_Request___c is saved:
Purchase_Request_Roll_Ups__c = a2D0f0000016gw2

 
Doug BurkhartDoug Burkhart
You just have to make sure that if you are uploading records that are going to start this process, that you are doing so in small batches so they can all process. It sounds like it's also possible that the Process is trying to run because of other changes to the record so I would confirm your criteria on the Process and make sure it is as specific as possible so that it only processes at the specific time you need to and not again after that (i.e. Only run if Purchase Request Roll Ups = null). As for the M/D though, you can change a lookup relationship to a Master Detail provided all Child Records have the lookup field populated. If you have past records that wouldn't apply, you could create one Parent Record (I'll call it Archives) to associate all the Child Records to so that you can transition to M/D if that's going to make it easier for you.
Scott WalkerScott Walker
The issue I have s that there are numerous users who can create this record (114 users) but nobosy is doing laods at the same time, maximum 30 total made by everyone a day I reckon so I am surprised this is causing an issue.

There are a large number of roll-ups that are generating and wonder if that has something to do with it.  Not linked to this process directly but maybe that causes an issue some other way?  Each record needs to have the same purchase request look-up generated.  I have never changed a record type and there are thousands of records now and not sure how to check the updates of this field.  IS there another way to update the field with what I need easily?
Doug BurkhartDoug Burkhart
If all of the records are being associated to the same Purchase Roll Up, consider doing this through a standard workflow with a field update instead. The value of the Process Builder is that it can be dynamic, but since the value is always the same, you don't actually have to do it that way. By using workflow, the issue should go away as it doesn't have the issues with processing batches that the Process Builder encounters.
Scott WalkerScott Walker
Ah let me try this.  Thanks Douglas, let me get back to you all.
Doug BurkhartDoug Burkhart
Yes, please keep me posted!
Scott WalkerScott Walker
As a list of fields I can update the one I need isn't listed.  Is it possible you are unable to update a lookup field?
Doug BurkhartDoug Burkhart
Ahh, that's my fault. It's limited to User Lookup Fields, not related record lookups. Let's revisit the Process Builder. What's the criteria you are using to determine which records to update? Can you post a screenshot?

f we can get that to limit the ones it even attempts to process, we might be able to bypass the error.
Scott WalkerScott Walker
Would possibly making the process builder action delayed help do you think?
Scott WalkerScott Walker
OK so these are the screennshotsUser-added image

User-added image
Doug BurkhartDoug Burkhart
What is the criteria being used in the node for "Update Purchase Request Lookup" that tells the Process which records to process and attempt to update?
Scott WalkerScott Walker
ah yes its the No criteria—just execute the actions!
Doug BurkhartDoug Burkhart
That's where I would consider adding criteria. Example:

Purchase Request Rolls up - Is Null - Boolean - True

This way, the Process will only even attempt to update records where the Purchase Request Roll Ups hasn't been populated.

Start there and if any other criteria can further filter it, I would add that as well.

Doug
Scott WalkerScott Walker
OK geat, let me try that
Scott WalkerScott Walker
Still causes the error I'm afraid, so weird.  There haven't been any others today so its so odd to me this issue comes up.
Doug BurkhartDoug Burkhart
Was it definitely the same error message?

I see that on the previous one, the process was triggered by Aaron Louie. What is his role? Would he be running any updates? What records would he be touching that could trigger this process?
Scott WalkerScott Walker
Everyone has access to the purcase request object.  Basically its a form where you can order items for purchase approval.

This is the current error message:

FlowApplication <info@salesforce.com>2:23 PM (4 minutes ago)
to me
Error element myRule_1_A1 (FlowRecordUpdate).
The flow tried to update these records: null. This error occurred: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: dlrs_Purchase_Request_FormTrigger: System.LimitException: dlrs:Too many SOQL queries: 101. For details, see API Exceptions.

This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.

Flow Details
Flow Name: PRRU_000001date_Purchase_Request
Type: Workflow
Version: 3
Status: Active

Flow Interview Details
Interview Label: 
Current User: Scott Walker (005G0000003uXRC)
Start time: 9/19/2017 2:23 PM
Duration: 0 seconds

How the Interview Started
Scott Walker (005G0000003uXRC) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = null
myVariable_current = a4s0f000000XyUdAAK

ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "9/19/2017 2:23 PM"

DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Purchase_Request_Roll_Ups__c} (null) Is null true
Logic: All conditions must be true (AND)

RECORD UPDATE: myRule_1_A1
Find all Purchase_Request_Form__c records where:
Id Equals {!myVariable_current.Id} (a4s0f000000XyUdAAK)
Update the records’ field values.
Purchase_Request_Roll_Ups__c = a2D0f0000016gw2
Result
Failed to update records that meet the filter criteria.


Could the issue be caused by something else at all?  It was working all day then just stopped.  I have created a coule of extra roll-ups today that are not linkd to this process at all but is linked to the object.  I can't see hwo that woudl be possible but this is just so bizarre to me
Scott WalkerScott Walker
This is the personal error message that comes up within salesforce (the other errors I posted are what are emailed to me when there is an error)

Workflow Action Failed to Trigger Flow
The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3010f000000XqfN. Flow error messages: &lt;b&gt;An unhandled fault has occurred in this flow&lt;/b&gt;&lt;br&gt;An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help. 

Click here to return to the previous page.
Doug BurkhartDoug Burkhart
Because everything is interconnected, it could be a lot of things. What is the Roll Up Tool you are using? I have used one in the past and it couldn't process records related to a single record if they reached a certain threshold. I would run a quick report on Purchase Request Roll Ups with Purchase Requests and see how many Purchase Requests are associated with the Purchase Request Roll Ups where ID = a2D0f0000016gw2. It could be an issue with the roll up tool not being able to process and so records aren't getting properly updated/created.

Doug
Scott WalkerScott Walker
Its called lookup roll-up summaries - the link to the github for it is here - https://github.com/afawcett/declarative-lookup-rollup-summaries
Scott WalkerScott Walker
Oh weird.  I just deleted the 4 new lookups I made today and its woring again.  The 4 today have a slightly different SOQL query.  COuld that change be something to do with it?  Its a totally minor change and unsure why it would cause the issue.  I could try and put one of the new ones backback and see if it works?
Doug BurkhartDoug Burkhart
Scott,

I think that's the issue. In the article you provided, there is a Usage Information and Known Issues section that points to some other articles. One of those is paltform limitations: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm. In the table you can see there is a limit of 50,000 for Total number of records retrieved by SOQL queries which falls in line with your error message of Too Many SOQL queries. I think what's happening is that anytime you add a record that is being updated via the Process Builder, that Purchase Request Roll Up record has to re-process via apex all of the Purchase Requests associated with it so that it can formulate what value belongs in the rollup field. Because of the number of records related to it, it is hitting limits in trying to compute that value and the result is the error.

​Doug
Doug BurkhartDoug Burkhart
Unfortunately, I've used that tool myself and couldn't find a way around that issue. I ended up having to make it a M/D relationship so that I could use the standard Salesforce Rollup Summary Fields.
Scott WalkerScott Walker
Ah ok thanks Douglas, thats a real shame.  If I was to batch schedule the lookups rather than do them in real-time do you think that would help at all?
If not are there any good documents on how to comvert my lookup to an M/D at all?  Alo will this allow for different lookups being created and decided upon by the picklist values?

Really appreciate your help Douglas and thanks for sticking with this.
Doug BurkhartDoug Burkhart
Happy to help you see this through.

I don't think the batch scheduling will work because it's not a matter of the updates running, it's an issue with them processing due to the number of records the rollup has to run back through on the back side.

As far as converting to M/D, that it not as difficult as it sounds. The first requirement is to ensure that every Purchase Request Record has a Purchase Request Rollup Record populated in the Lookup field. So, I would do the following:

1) Deactive the Declarative Rollup Summary
2) Create a new Purchase Request Rollup Record (This will be the Master for all of the archived records you don't want on the current record with ID = a2D0f0000016gw2)
3) Populate all previous Purchase Requests with the ID of the newly created Rollup record (mass update via data loader)
4) Confirm via reporting that all Purchase Requests have the Rollup Lookup field populated.
5) Edit lookup field to change field type to M/D
6) Create rollup summary fields on Rollup Record Object (Yes, you can use picklists to filter which records get rolled up)

Doug
This was selected as the best answer
Scott WalkerScott Walker
This is amazing thanks so much.  I am 100% going to do this when I get a second. Going forward it has to be the best solution huh.  

Out of interested do you knwo if its possibe to create some way of updating all the lookup field once a month for those that have been created by using a workflow or something?  Someway of doing this update once a month for the previous month would be good so this way it wont do it each time a purchase request is made but at a set date.  maybe that ight help with the processing?

I will close this Q&A out after ths Doug, agan, really appreciate your time on this one
Doug BurkhartDoug Burkhart
Scott,

I apologize but I overlooked something. In order to have the M/D, the Master Record HAS to be populated at creation. So, you won't be able to do this since that is the field you are trying to update via the Process Builder. Unless you are willing to have your Users define the Rollup record when creating the Purchase Requests then you can get the rollup you want and you wouldn't need a process to update that field.

Sorry for the oversight.

Doug
Doug BurkhartDoug Burkhart
So, it's kind of a chicken or the egg scenario. The Rollup Summary is stopping the Process from Operating but the Process is trying to update a field that would allow the Rollup Summary to be accurate. In we switch the M/D to fix the rollup summary issue, the field the Process is trying to update becomes required so it can no longer be left blank upon creation.

Is it possible that you could alter the Process to make sure you Users select that Rollup Record when creating the Purchase Requests? Since it's always the same value, there shouldn't be any guess work.

Doug
Scott WalkerScott Walker
I see what you are saying yes but thats an excellent idea to complete the rollup record also, let me look into that.