Tuesday 3 March 2020

How to Upload Google Docs in Salesforce Lightning Interface

Use Case: Do you or your team have been used to attach google docs when you are in Salesforce classic interface? How did you feel once you migrated to Lightning and figured it out that "Add Google Doc" button is missing. Sad right. This is exactly I felt when we are doing the demo to our own internal team who uses google sheets extensively and had to announce they need to switch back to classic interface to upload google docs. Who would like to do that and once they switch back to classic they stay in the same interface without switching back to classic and it reduces lightning adoption usage.

I did some research online and could not find any helpful resources like how others overcome this issue. I could just find out that the idea was posted and waiting for Salesforce to get it delivered.

Here is the idea in the success community to provide the Add Google Doc button in Lightning. Please upvote it.


Solution

Ideally my goal is to figure it out whether attaching google docs is supported in Lightning interface or not. Is Salesforce just hiding the button or the whole functionality it self is supported or not. 

I started with building a lightning component to fetch the google docs for a given record using apex controller to see if it actually retrieves data or not.

Let us first see the below apex controller. It accepts the String parameter and fetches the google docs available for the given record.


Below is the Lightning Component which uses Lightning Data Table to display the retrieved docs.

Below is the related java script controller which then calls the helper method

Below is the actual helper method which calls the apex controller method to fetch the google docs records and assign it to the gdocs attribute

At this point of time when I placed this component on the Account record page and was expecting an error message which says "Thanks for all your efforts but google docs is not supported in Lightning" , but I was shocked to see the below result. As you can see in the below screenshot I was able to get the existing docs for the record and was able to display them in the Lightning Interface. 



So it became very clear to me that it was just actually the button was missing and not the whole functionality and we can custom code it. 

So in below snippets you can find the complete code to display, add and delete the existing records in Lightning Interface with out users ever need to switch back to classic interface.

Apex Class

Apex Test Class(This can be improved but I am just providing for your reference)

Lightning Component

Lightning Component Java Script Controller

Lightning Component Java Script Helper



And a couple of screenshots to show how it looks:










  If this post really helped you to fix your issue please let me know in the comments section. Also please share it with your friends who can benefit from similar situation.

P.S: This is my very first blog post, so if you see anything that can be improved in the post, please do suggest in the comments section. Thanks.

8 comments:

  1. This is so awesome! Thank you for writing this post. I also thought that the functionality of adding google docs was lost in Lightning. It is so amazing that you created the workaround. Will be sure to try it!

    ReplyDelete
  2. Thanks so much!!! I just implemented this and it works perfectly. Great job!

    ReplyDelete
  3. so you need to add every one of those components for it to work? (Javascript controller / helper , and the usuals of Class/Test/lightning component)

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Hi! Awesome coding skills that you have, I am very impressed.
    By the way, do you believe it would be possible to show, edit and save a google spreadsheet as another component of the page layout of a record?

    ReplyDelete