0

Instead of Managed Sharing through Apex, I used flow to share Account records via Flows.

I would like to share the record with another user via the Secondary_Owner__c field in Account. I also want the sharing to be dynamic when it comes to update or deletion of the value in the lookup field. For instance, if Secondary_Owner__c is John Doe and it is changed to Jane Doe, I want the AccountShare record to be removed and add Jane Doe.

I have two flows in a Process Builder (PB). 1st flow gets and removes all AccountShare records where rowCause=Manual. 2nd flow adds the AccountShare record based on Secondary_Owner__c field. The PB conditions are when the Secondary_Owner__c is changed & not blank.

Individually, each flow works. However, when there are no AccountShare records in the get part of the 1st flow, it errors out and the rest of the flows break. Any idea on how to handle the error?

Flow API Name: Delete_Current_AccountShare_Ids
Type: Autolaunched Flow
Version: 1
Status: Active
Org: Wedbush Securities (00D1I000001f2ry)
Flow Interview Details
Interview Label: Delete Current AccountShare Ids 3/3/2020 1:34 PM
Current User: John Doe (0051I000004xz2w)
Start time: 3/3/2020 1:34 PM
Duration: 0 seconds
How the Interview Started
John Doe (0051I000004xz2w) started the flow interview.
FAST LOOKUP: Get_Current_AccountShare_Ids
Find all AccountShare records where:
AccountId Equals {!AccountIDs} (null)
RowCause Equals Manual
Store the values of these fields in Get_Current_AccountShare_Ids: Id, RowCause
Result
Failed to find records.
FAST DELETE: Delete_AccountShare_Ids
Delete AccountShare records whose IDs are stored in {!Get_Current_AccountShare_Ids}.
Variable Values
None.
Result
Failed to delete records whose IDs are in {!Get_Current_AccountShare_Ids}.
Error Occurred: No records in Salesforce match your delete criteria.




1
  • In your first flow you need a Decision element to test if the Get Records returns any records, and proceed if it does. Apr 17, 2020 at 23:05

1 Answer 1

0

Before you do a delete (of null which is failing), assign a variable a count of the number of manuals you find. Then add a decision if the count is zero, don't proceed with a delete. If greater than zero, do the delete action.

-- Edit: I was thinking in terms of a flow, not a process builder. Could use the PB to kick off a flow to complete the above actions. Not sure if PB could do a count thing I mentioned.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .