I need to change an existing flow and add a function to it to add or change the sharing of records that are private in OWD to read/write with a public group. I know it's easy with apex but my customer wants it done with Flow if possible. Anyone know how to do this?
-
You can create a custom checkbox field on Object and mark it checked in flow. Later, create a sharing rule that will check the checkbox and share the record with group of users.– Shailesh PatilCommented Feb 26, 2016 at 8:33
-
Thanks, but I need it to share dynamically based n field in the record– SaskiahCommented Feb 29, 2016 at 8:28
1 Answer
It's probably easier with Apex but it can be done with Flow also. Follow these steps:
Create an Apex Sharing Reason on your chosen object, say 'Yourobject': Setup > Build > Create > Objects > Yourobject and then click the 'New' button in the Apex Sharing Reasons related list
Now create a Flow: Setup > Build > Create > Workflows & Approvals > Flows. On the Canvas, create two text variables: VarT_YourobjectId and VarT_YourgroupId.
Now have the flow create a record on the Yourobject_Share object. This object is related to Yourobject and stores all sharing records. Drag and drop the Record Create element onto the Flow Canvas. A window will open where you enter a name for your flow.
In the Accesslevel field on the Canvas, choose the access level for Yourgroup
In the ParentId field, choose the VarT_YourobjectId variable from the picklist
In the UserOrGroupId, choose the VarT_YourgroupId variable from the picklist
In the Rowcause field, choose the Apex sharing reason you created from the Picklist Values
Now, save your Flow and create a process with Process Builder that invokes your Flow. You map the Flow variables that you created to the fields on Yourobject that contain the Yourobject Id and the group Id you need to share the record with.
-
This way I can share dynamcally? Based on a field in the record?– SaskiahCommented Feb 29, 2016 at 8:27
-
Yes, you can share with a user or group, provided that the id is stored in your object– user28311Commented Feb 29, 2016 at 8:52
-
I've been doing exactly as you said, but it is not working, and no no error message– SaskiahCommented Feb 29, 2016 at 13:55
-
Can you see in the debug log what happened? You have set the workflow picklist to 'finer'– user28311Commented Feb 29, 2016 at 15:06
-
It's working! It was not activated (thought I did) Thanks Fred– SaskiahCommented Mar 1, 2016 at 8:18