Friday, April 17, 2020

Get the Content (Blob) of File from Box and Store/Manipulate it in Salesforce

Through this blog, I am going to share sample apex script through which you can get content of file from box as blob and then store or manipulate it within salesforce.

I have already written a blog to explain how to get box access token (needed for handshake with Box) and to display file content in salesforce in VF page without storing it in salesforce. You can cosider it as Mashup inSalesforce. Please refer below URL to that:

Box and Salesforce Integration

In order to get box file content, we need to have box file Id and box access token.

Box does not provide direct API to get file content. First you need to do callout to get download URL and then you perform another API callout to get file content. Also you perform another API call to get file details like filename in order to store it in salesforce.

I am going to store box file in salesforce library for demo purpose. You can store it as attachments or read the content on the fly to perform some logic instead of saving it.

Add below URLs in remote site settings before performing the callouts:
  • https://api.box.com
  • https://dl.boxcloud.com 

Below is required code and it is self explainatory as comments are mentioned for each methods:

Now run below script in developer console:

string boxFileId='6542xxx28604';
string access_token='0xxxxxxxxxxxxxxxxxxxxxxxxxxxredx0P';
string sfdcLibraryName='Box_File_Library';
string boxFilename= SK_BoxAPIUtilityClass.findFileNameFromBox(boxFileId,access_token);
system.debug('****boxFilename:'+boxFilename);
SK_BoxAPIUtilityClass.readFileContentFromBox(boxFileId,boxFilename,sfdcLibraryName,access_token);



Use Case

During sandbox refresh, all custom settings data gets refreshed from production values. So before refresh, you have to take back up each custom settings data and after refresh, you need to update the custom setting records. In order to automate this, you can write script through which you can push all custom setting data to box folder. Code to upload the files from Salesforce to box is already shared in blog  Box and Salesforce Integration.

Now we need to get the content of all csv files stored in box and update the custom setting in salesforce. Once you get the content of file, you can parse csv file and update custom settings.

Hope this helps!!!


32 comments:

  1. I am looking for and I love to post a comment that "The content of your post is awesome" Great work!

    360DigiTMG

    ReplyDelete
  2. Market your store. Whenever you have the store ready for action you need to out some work into it; this is where most stores begin to fall flat.besimple.com/

    ReplyDelete
  3. What job doesn’t require attention to detail? But recently, I witnessed first hand, a group of professionals whose entire workload is attention to detail. get detail

    ReplyDelete
  4. Interchange fees published by the card brands such as Visa and MasterCard dictate the underlying costs of all credit card processing charges.Gun Credit Card Processing

    ReplyDelete
  5. Interesting topic for a blog. I have been searching the Internet for fun and came upon your website. Fabulous post. Thanks a ton for sharing your knowledge! It is great to see that some people still put in an effort into managing their websites. I'll be sure to check back again real soon. email marketing costs

    ReplyDelete
  6. Likewise, get data about the installment mode.transfer large files

    ReplyDelete
  7. Over time, it became common to get good grades as soon as this site https://bestessaytyper.com/write-my-essay asked me to do so, where they do any writing work in no time, with high quality and low prices, convenient for everyone.

    ReplyDelete
  8. I am now not certain the place you’re getting your information, but good topic... Content Management Systems

    ReplyDelete
  9. Such a wonder is currently underestimated by numerous individuals of us. Furthermore, it is the sheer volume of the store that permits it to stock all and anything one may require including administrations, for example, a hair style, a nail salon, and even cafés and banks. Why go elsewhere in the event that you can get everything in just one stop? https://open4u.co.uk/branches/farmfoods.html

    ReplyDelete
  10. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. 성인

    ReplyDelete
  11. A squashed box won't be solid. You need to be certain that the crates are dry, since moving boxes that were wet will handily self-destruct. I realize that this will sound somewhat interesting, yet ensure the cases don't have an awful stench! Mylabs

    ReplyDelete
  12. Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. content marketing for small businesses

    ReplyDelete
  13. In the event that 'giving your retail outlet a new look' is the thing that you are searching for, here is the thing that we are taking a gander at. selective pallet racking system

    ReplyDelete
  14. A great content material as well as great layout. Your website deserves all of the positive feedback it’s been getting. I will be back soon for further quality contents. convert pdf to png

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. Your articles are inventive. I am looking forward to reading the plethora of articles that you have linked here. Thumbs up! http://www.mamafamille.ca/

    ReplyDelete
  17. i am always looking for some free stuffs over the internet. there are also some companies which gives free samples. Boutique cadeau

    ReplyDelete
  18. Really I enjoy your site with effective and useful information. It is included very nice post with a lot of our resources.thanks for share. i enjoy this post. file upload

    ReplyDelete
  19. Do you need Finance? Are you looking for Finance? Are you looking for finance to enlarge your business? We help individuals and companies to obtain finance for business expanding and to setup a new business ranging any amount. Get finance at affordable interest rate of 3%, Do you need this finance for business and to clear your bills? Then send us an email now for more information contact us now via (financialserviceoffer876@gmail.com) whats-App +918929509036 Dr James Eric Finance Pvt Ltd Thanks

    ReplyDelete
  20. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. convert pdf to png

    ReplyDelete
  21. Advances in interchanges and innovation have carried with it an off-shoot marvel that has significantly affected the manner in which people and organizations interface and manage one another.mz header

    ReplyDelete
  22. Nice to be visiting your blog once more, it has been months for me. Well this article that ive been waited for therefore long. i want this article to finish my assignment within the faculty, and it has same topic together with your article. Thanks, nice share. 먹튀사이트

    ReplyDelete
  23. Cool stuff you have got and you keep update all of us. 메이저사이트

    ReplyDelete
  24. I really like your writing style, great information, thankyou for posting. 먹튀검증

    ReplyDelete
  25. i am always looking for some free stuffs over the internet. there are also some companies which gives free samples. 먹튀검증

    ReplyDelete
  26. vYes, I am entirely agreed with this article, and I just want say that this article is very helpful and enlightening. I also have some precious piece of concerned info !!!!!!Thanks. BizOp

    ReplyDelete
  27. It helps you to build better internal resources along with a good staffing. salesforce interview questions latest

    ReplyDelete
  28. Cool stuff you have got and you keep update all of us. 안전놀이터

    ReplyDelete
  29. Thankyou for this wondrous post, I am glad I observed this website on yahoo. 토토사이트

    ReplyDelete
  30. Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home. 릴게임

    ReplyDelete