新しいBoxサポートサイトへようこそ。 変更点の詳細はこちらをご確認ください .

createFileFromAttachment

新規投稿

コメント

3件のコメント

  • Murtza

    Just to clarify, are you using the Box Salesforce SDK or the Box For Salesforce: Developer Toolkit
    for this integration? 

    0
    コメントアクション Permalink
  • dlansing
    Attachment a = [SELECT Id, Name, Body, ParentId 
                             FROM Attachment
                             WHERE Id =: attachmentId];
    box.Toolkit boxToolkit = new box.Toolkit();
    /* createFileFromAttachment params:
        Attachment att - required - This is the file to add in Box
    
        String fileNameOverride - optional/null - If a non-null value is sent, that will be the name of the file in Box (be sure to include the extension)
    
        String folderIdOverride - optional/null - If a value is sent, the attachment will be uploaded to this folder id.  Otherwise, it is uploaded to the folder associated with this salesforce record.  If no folder exists, one will be created
    
        String accessToken - optional/null - If a value is sent, this will be used as the accessToken to connect to box.  Otherwise, the service user credentials are used.  Generally this is sent as null.
    */
    
    String fileId = boxToolkit.createFileFromAttachment(a, null, null, null);
    boxToolkit.commitChanges();
    
    // optionally do something with fileId if needed
    

    You're correct in how you understand this function to work.  If a folder doesn't exist for the current Salesforce record, one is created.  The integration must be fully set up for this method to work (service account set up, root folder created, etc).

     

    The Attachment object you pass must include the fields; Name, Body, and ParentId for the method to execute successfully.

    0
    コメントアクション Permalink
  • lynng

    I get this error when I use that code:

     

    Exception caught when preparing to create a file on Box: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out.

     

    Can someone tell me why?

    0
    コメントアクション Permalink

サインインしてコメントを残してください。