Welcome to the new Box Support website. Check out all the details here on what’s changed.

Comments

7 comments

  • Official comment
    Alex Novotny

    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 Permalink
  • LinThaw

    Thanks Alex, I will try first with toolkit.

     

    0
    Comment actions Permalink
  • LinThaw

    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?

    0
    Comment actions Permalink
  • Alex Novotny

    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 

    0
    Comment actions Permalink
  • LinThaw

    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);
    0
    Comment actions Permalink
  • Alex Novotny

    Ah! Yes, I forgot that generic method example was in there! Good find! You do not need to use this unless you are adding metadata to a custom template. 

    Thanks, 

    Alex

    1
    Comment actions Permalink
  • LinThaw

    Thanks.

    0
    Comment actions Permalink

Please sign in to leave a comment.