Salesforce to Box
Hi,
If we have already installed Box SDK for Salesforce package,
do we need to install Salesforce Developer Toolkit to develop custom business requirements like this.
Thanks
-
Official comment
Hey Lin,
The Box SDK for Salesforce and the Salesforce Developer Toolkit are actually different packages. The toolkit is installed with the standard package, allowing you to make specific method calls as outlined here out of the box.The SDK allows you to do fully customized logic. Every customer's use case is different, so I can't provide any more guidance without first knowing what use case you are trying to solve for. I would have a look through the methods the toolkit provides to see if they will solve the problem you want to automate. You can also reach out to our Box Consulting group to ask about a consulting package geared toward SFDC training.
Thanks,
Alex, Box Developer Advocate
Comment actions -
Hi Alex,
I am trying to create box folder for salesforce record and to upload attachment to that folder via apex.
with toolkit, I will use following methods.
- createFolderForRecordId
- createCollaborationOnRecord
- createFileFromAttachment
1. Do I need to use CreateMetaDataForFolder method?
2. And I want to use method createFile only (no From Attachment), is it possible with toolkit?
-
Hi Lin,
The only methods available in the toolkit are the ones listed here. I don't actually see a CreateMetadataForFolder method in that list... are you seeing it somewhere else?
Thanks,
Alex, Box Developer Advocate
-
Hi Alex,
Thanks.
I found it here and sorry I named it in Apex.
Construct metadata of object and use Http POST as generic and authentication via toolkit.
// Instantiate the Toolkit object box.Toolkit toolkit = new box.Toolkit(); // Get the Salesforce record id associated with a Box folder String recordId = toolkit.getRecordIdByFolderId('{some folder id}'); // Construct an object containing all the metadata you want Map<String, Object> metadata = new Map<String, Object>{ 'salesforce_id' => recordId, 'salesforce_url' => System.URL.getSalesforceBaseUrl().toExternalForm() + '/' + recordId, 'salesforce_user_name' => UserInfo.getName(), 'salesforce_user_email' => UserInfo.getUserEmail() }; // Specify the Box API endpoint to call String endpoint = 'https://api.box.com/2.0/folders/' + '{some folder id}' + '/metadata/global/properties'; // Create a new HttpRequest object and set appropriate values HttpRequest request = new HttpRequest(); request.setMethod('POST'); request.setEndpoint(endpoint); request.setBody(JSON.serialize(metadata)); request.setHeader('content-type', 'application/json'); // Send the HttpRequest through the generic Toolkit method, which will handle the authentication details HttpResponse response = toolkit.sendRequest(request);
Please sign in to leave a comment.
Comments
7 comments