Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transfer Salesforce(Chatter) Files to Google Drive #4

Open
TonyJaensch opened this issue Mar 28, 2017 · 6 comments
Open

Transfer Salesforce(Chatter) Files to Google Drive #4

TonyJaensch opened this issue Mar 28, 2017 · 6 comments

Comments

@TonyJaensch
Copy link

Hi,

Is it possible to use these API libraries to create a trigger that will move the file from the Salesforce side of its Files object, and into the associated Google Drive external data source?

My thought was that, if it were possible, you would be able to retain the functionality of uploading a file to a record - from desktop or mobile applications -, and be able to view that same file on both devices, all the while hosting the file on Google Drive, thereby avoid filling up your data allocation on the (costly) Force platform.

@mwoodcertinia
Copy link

Yes, it is possible to use these libraries to move files from Salesforce to Google Drive. Indeed, your use case is the one that prompted us to write this library.

A sample app demonstrating moving files from Salesforce to Google Drive can be found here. Although this doesn't use a trigger, it would be possible to adapt it in this way.

@TonyJaensch
Copy link
Author

HI Matt,

Thanks for the response.

I installed that Sample App and set everything up, but when I click on the Move Attachments to Google Drive button, the visualforce page that displays shows no files in either the Account Attachments or the Account Google Drive Files.

The Test Harness says that everything has been successfully authenticated, and when I try a File Insert in the test harness it all goes through fine.

Initially I thought it was because this was searching for the old "Attachments" and not the new Salesforce Files, but am I missing some permission or setting that is stopping the button from working?

The other thing I wanted to ask is that I have to reauthenticate by going into the Connector object and clicking activate. Is this just because I'm doing this in a Sandbox environment or do I need to adjust some of the coding so that it will automatically reauthenticate when it needs to?

@TonyJaensch
Copy link
Author

Just to follow up:

I believe the issue lies in the "Files"/"Attachments" definition as when I uploading a picture from a visualforce page that uploads as an attachment and not a salesforce file, the button did allow me to transfer the image over, saving it as a note with a URL link to the file hosted on Google Drive.

I guess the next question is if there is any way to parse this through files connect, and rather than having a note with a URL, have the file connected to the object record via ContentDocumentLink?

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentdocumentlink.htm

@mwoodcertinia
Copy link

Regarding the reauthentication question, the method ffhttp_OAuthClient.exchangeRefreshTokenRequest should allow you to reauthenticate when required (assuming that you have a valid refresh token from the authorisation process).

Looking at the sample app, the ConnectorService.validateConnector and ConnectorService.exchangeCode methods give an indication of how this method can be used to do this. However, in this example you have to go the connector page to prompt the reauthentication process.

As you have seen, the 'Transfer to Google Drive' button transfers the file from Salesforce and creates a note with the URL. It may be that the ContentDocumentLink is more appropriate in which case the GoogleDriveAccountController.transferAttachmentToGoogleDrive would be the method to change.

@TonyJaensch
Copy link
Author

I see, thanks for the response.

I apologize if many of these seem simple questions. This is my first real forray into the Dev side of Salesforce so I will probably have to go back and do some more thorough reading to understand how to apply the method you mention to my application.

Similarly with using ContentDocumentLink, what would be the method that you would recommend to enable me to identify which file in Google Drive to update.

I'm guessing to queryAll() of the ContentDocuments by Title (unless there is a way to query it by the external object Url), in order to get the FileID, before creating a LinkedEntityId for the record that the whole visualforce page was invoke from?

Would that seem logical, or is there something glaring that I'm overlooking?

@PJJPtx
Copy link

PJJPtx commented Jul 25, 2018

Tony, I am looking to do the exact same thing as you. Were you able to accomplish it? If so, Please do share... THANK YOU!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants