createFileFromAttachment
Hello folks,
We're integrating box with Salesforce and for existing attachement into salesforce records, I want to leverage "createFileFromAttachment", if I under stood correctly this function will create respective folder at box and copy attached files in it. Does any one have used this, I'm not sure on how to use this function inside apex. Initiation/parameters etc. Any Sample code or advise?
Thanks
-
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.
サインインしてコメントを残してください。
コメント
3件のコメント