function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sean McMickleSean McMickle 

Sharing OneDrive files using Apex

I have not been able to find any documentation regarding sharing OneDrive files using Apex. Does anyone have an example or a resource that they could give?

I would like to be able to use condition based triggers to attach particular files from particular folders from OneDrive to particular objects.

Thanks!

-Sean
@Karanraj@Karanraj
You have follow the below steps to achieve this 

1. First you need to authenticate with onedrive to perform any operation from the external system. Using name crendtials you can authenticate into oneDrive without hard coding user crendtials in the apex class.
OneDrive oAuth process - https://dev.onedrive.com/auth/msa_oauth.htm
Salesforce external authentication providers - https://help.salesforce.com/htviewhelpdoc?err=1&id=sso_authentication_providers.htm&siteLang=en_US (https://help.salesforce.com/htviewhelpdoc?err=1&id=sso_authentication_providers.htm&siteLang=en_US
Salesforce Named Crendtials -  http://​https://help.salesforce.com/HTViewSolution?id=000206761&language=en_US (http://​https://help.salesforce.com/HTViewSolution?id=000206761&language=en_US)

2. Then you have make http callouts from salesforce to write files in the OneDrive folder 
Write files in OneDrive - https://dev.onedrive.com/items/create.htm
Apex HTTP callouts - https://developer.salesforce.com/docs/atlas.en-us.200.0.apexcode.meta/apexcode/apex_callouts_http.htm
Apex HTTP callouts Trailhead module - https://developer.salesforce.com/trailhead/apex_integration_services/apex_integration_rest_callouts
Dhanik L SahniDhanik L Sahni
Hello,
Refer blog https://salesforcecodex.com/2020/09/uploading-files-to-microsoft-one-drive-using-apex/ for direct integration with Microsoft one drive using apex.

Thank you,
Dhanik
James DornJames Dorn
You can try the integration using the Skyvia service, this article describes the integration options
Read more here (https://blog.skyvia.com/onedrive-salesforce-integration/)