 Hello friends. I'm Sanjay Gupta. I welcome you on Sanjay Gupta tech school in this video. I'm going to demonstrate how you can manually share a record using lightning flow in Salesforce. So the scenario is in my org for contact and case object is private. And if case owner can access a particular case, then that owner should be able to view contact details as well. So basically, if I am the owner of the case and contact is populated on that case and owner of that contact is another user, then also I should be able to view the contact details. So what we need to do whenever case is assigned to you, then we need to make sure the owner of the case should be able to access contact details. So we are going to do this with the help of manual sharing using flow. So what do we need to do? We need to set OWD first, then I will be creating a case and will be populating a contact. So with same user, I will be creating case and contact. So owner of case and contact will be same user. Then I will be assigning the case to another user. So at this time, case will be owned by another user and contact will be owned by another user. So we need to check whether the new case owner can access contact record or not. So if no, then we need to create a flow to share the contact with the case and we need to call that flow through process builder. So first I will set OWD, then I will create a case and contact, then I will be assigning case to another user and will show you like whether that new case owner can access the contact or not. Then we will build a solution for this problem. So moving to my org, so here I'm going to search for sharing setting. So OWD basically stands for organization wide defaults. So in sharing setting here you can see organization wide defaults are available. So right now contact is controlled by parent. So it is basically controlled by account. So account is having public read write and cases already private. So I'm going to change the OWD for contact. Clicking on save. So here you can see the warning one or more sharing operation has been initiated. See below for additional details. Certain operations may not be available. So basically it is, yeah, it is recalculating the sharing rules. So now I am doing a refresh and going to check my email. So here I have received one email. So your request to change your organization by sharing defaults has successfully completed. So mail is there and now after refreshing, I need to check whether it is set to private or not. Yeah, it is set. Contact is now private and case is also private. Now moving to case creation. So here you can see I have already created a case. So owner is Sanjay Gupta and contact is this. So I am opening this contact in another tab. So we need to check the owner of this contact as well. So in the details we can see. So contact owner is also Sanjay Gupta right now in my org. I have one more user. So let me show you so that we can log in with that user. So here you can see this is the current user with which I am logged in that is system admin and another one is Vikas Gupta, which is a normal standard user profile user. So I'm going to assign the case to this user and then we will log in and check whether we are able to access contact through this Vikas Gupta user or not. So I'm moving to case changing the case owner. So case owner is changed. Let's check the contact as well. So I'm going to refresh the contact refreshing case as well. So, so the contact details you can see contact is still owned by Sanjay and the case is now owned by Vikas right. So now I'm going to log in with Vikas. So case number is 1036 that we need to access and clicking on case all open cases. So here you can see only one cases available. So Vikas can access this case because Vikas is the owner of this case. Now I'm going to click on this contact. So here you can see looks like there's a problem. Unfortunately, there was a problem. Please try again if the problem continues get in touch with your administrator with the error ID show here. So this way this error is coming here because OWD is private and Vikas is not the owner of contact. So this user won't be able to access the contact details. Now we need to build a solution for this problem like whenever I am assigning a case from one user to another user. So in the background, some automation should be there which will automatically share the related contact with that case owner so that a case owner can access the account. Sorry, can access the contact as well. Right. So now we are going to do that with help of flow. So I hope you understood the problem. So if you are sharing a record so you can. Sorry, if you are assigning a record to another user and if you want to share the related record then we can do that with the help of flow using manual sharing. So I'm selecting auto launch flow and this auto launch flow I will be calling through process builder because we need to apply some condition like when we need to execute this flow. So for those I will be implementing in process builder. So here. So this auto launch flow will be receiving the case owner ID and case contact ID. Right. So I'm just going to use this create record element. So create contact share record. Right. And use separate resource and literal values. So here I'm searching for contact share and here I need to pass those values. So I need to receive the case owner ID and the contact ID which is populated on the case for that purpose. First I need to create two variables. So I'm going to create two new resources first. So this is owner ID. And remember to check this checkbox available for input because this value will be provided by the process builder. Again, contact ID available for input. So these two values will be available through process builder. So now we can create this content share record. Use separate resources object. We can select contact share. Now here we need to select these fields. So contact ID. I'm assigning like which contact record we need to share then user group ID with which we are going to share. So the new case owner will be. So with new case owner this contact record will be shared so contact ID is there and owner ID so contact will be shared with this user. Then contact access level. So here you can set like read write read only so how that record will be shared. So I'm selecting read only. It means the case owner can view the contact details that owner cannot modify the content. Right. And if required read write you can select that as well. And last one is both pause. So here I'm selecting manual share. So this way all these information are provided. So this record will be created. I'm going to save this. I'm naming it as contact share only activating this. So after this I need to create a process builder where I can put the condition and based on those conditions. This flow will be called. So I'm creating new process builder. So contact share with case owner. So this process starts when the court changes. Then I am going to select a case. Sorry object as case. I need to put the criteria here. So I'm going to put a condition owner ID is changed to then owner ID starts with. So let's build a formula because that will be more easy. So here I'm going to choose a function is changed. Then I'm going to pick the field as owner ID. So if owner ID is changed, then and next is begins. So here we need to put the text and the compare text. So here I'm going to put that owner ID and compare text will be 005. The user ID begins with 005. It means it belongs to a user and because there may be chances like you are assigning a case to Q maybe. So we can share a contact when his owner is a user because with that user we are going to share the content and is blank. And here I'm going to put the contact ID. I need to make sure on case contact ID must be populated. So if you are going to change owner ID and it begins with this and case cases having a particular contact populated in all these conditions are true. Then only we are going to call the flow criteria name. So check case details clicking on save. So here you can see contact share flow is available. So here we need to pass two things. First is owner ID and second is contact ID. So I'm selecting field reference for owner ID. So case owner ID we need to pass with which we need to share the contact and which contact we need to share that is also available on case. So I'm going to pass contact ID as well and clicking on save. So now we are ready activating this. Right now I'm opening one more case. So here you can see case owner is Sanjay Gupta which is current logged in user and I am selecting contact owner. Sorry, I'm selecting contact and whose owner is also Sanjay because this contact is already opened here. And this contact is owned by Sanjay. Now I'm going to assign this case to Vikas. So you will see when I will be logging in as Vikas. So Vikas can access case as well as the related contact because in the background process builder will fire and that process builder will be calling the flow flow will be sharing the contact with the current case owner. So I'm clicking on change owner. So owner is changed. Now I'm going to log in with Vikas. So this time you will see Vikas can see two cases because earlier we shared one case and that was 1036 and right now we shared one more case. That is 1035. So you can see. And if I open 1035. And if I click on this contact, so here you can see Vikas can view this contact and contact owner is Sanjay and OWD is private. Right. So this way, I hope you understood how we can share a particular record manually through automation with the help of flow and process builder. So I hope this video will help you to share records manually. If this kind of requirement is there. So I hope you understood whatever I demonstrated in this video regarding manual sharing of record using flow. And if you want to watch more Salesforce training videos so you can go to description of this video and you can find various links of playlist there. So do follow them. Thank you for watching this video.