+ Start a Discussion
Kanhaiya Yadav 4Kanhaiya Yadav 4 

how can create share button in Lighting ?

Hi,

  I am not able to share record in lighting like manual sharing in classic salesforce. Please guide me...

Thanks
Kanhaiya Yadav
NagendraNagendra (Salesforce Developers) 
Hi Yadav,

Sorry for this issue you are encountering.

If i understand your requirement correct that you want to share the record in lightning similar to as manual sharing in Salesforce classic, then I would suggest you please try with below steps.

MANUAL RECORD SHARING IN SALESFORCE LIGHTNING:

Did you know that in Lightning Experience, the button to share a record is impossible to add on any page layout? That is correct, if you use a private sharing model and want to manually share a record with other users, you’re expected to switch to classic to do so and then back to lightning.
I have created a simple workaround which allows you to have a button (technically an action) on a lightning page layout that will let you manually share a record as you could in classic. This entire process will take you less than 5 minutes
.
Step 1: Go to Visualforce Pages in your Salesforce settings, create a new page
You can name it whatever you want, I named mine “Sharing”
The code is simple:
<apex:page StandardController=”YOUR OBJECTS API NAME” action=”{!URLFOR($Action.YOUR OBJECTS API NAME.Share,YOUR OBJECTS API NAME.Id)}”>
</apex:page>
Replace my fillers with the API Name of your object for example “Opportunity” or “Custom_Object__c”
Now save the Visualforce page.

Step 2: Once you save, you’ll be returned to the list view of your Visualforce pages. Click Security next to your Visualforce page and add all the profiles you want to be able to manually share. I added them all for the sake of not running into accessibility issues.

Step 3: Go to the object settings that you created this Visualforce page for and find the Buttons, Links, and Actions section. Click New Action
Simply mimic what I did below
Save this action

Step 4: Go to your page layout(s) and add this action to the Salesforce1 and Lightning Experience Actions section. Save your page layout.
Voila! You now have a share button at the top of your lightning record page. Clicking it will bring you to the manual sharing page you’re used to in classic.

The workaround is successful.

For more information check this link. Hope this helps.

Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra
jane1234jane1234
as of now "sharing button" is still not available in Lightning Experience. Users will need to temporarily switch to Classic to view the information. This is on the roadmap for a future release coming soon.
https://help.salesforce.com/articleView?id=000232756&type=1
Kaylie FinnisKaylie Finnis
Hey all, I couldn't get the Visualforce Page to work that Nagendra recommended - got an error when trying to save. But here is a fix! It works as long as you already have all your sharing settings setup when you were in classic//know how to set up sharing.

Short term fix for anyone who is stuck that doesn't know VF:

Create a custom detail page button on the object. Save & add to page layout in the "Salesforce Mobile and Lightning Experience Actions"

Contact: https://YOUR_CLASSIC_ORG_URL/p/share/ConSharingDetail?parentId={!Contact.Id}

Custom Object: https://YOUR_CLASSIC_ORG_URL/p/share/CustomObjectSharingDetail?parentId={!OBJECT_API_NAME.Id}

your classic org url you can grab by switching to salesforce classic view. it usually looks something like:  "https://companyname.my.salesforce.com" 
 
Pina MaltesePina Maltese
Hi All,
this sharing button work fine in a Partner Community too?

Thanks