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!!!


49 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
  31. Great articles and great layout. Your blog post deserves all of the positive feedback it’s been getting. 먹튀검증

    ReplyDelete
  32. Hello I am so delighted I located your blog, I really located you by mistake, while I was watching on google for something else, Anyways I am here now and could just like to say thank for a tremendous post and a all round entertaining website. Please do keep up the great work. 먹튀검증

    ReplyDelete
  33. I am always looking for some free kinds of stuff over the internet. There are also some companies which give free samples. But after visiting your blog, I do not visit too many blogs. Thanks. 토토커뮤니티

    ReplyDelete
  34. This blog is so nice to me. I will keep on coming here again and again. Visit my link as well.. 88카

    ReplyDelete
  35. It proved to be Very helpful to me and I am sure to all the commentators here! how long are cbd gummies suppose to last after taking them

    ReplyDelete
  36. I visit your blog regularly and recommend it to all of those who wanted to enhance their knowledge with ease. The style of writing is excellent and also the content is top-notch. Thanks for that shrewdness you provide the readers! creative business names

    ReplyDelete
  37. Having read this I believed it was extremely informative. I appreciate you finding the time and energy to put this content together. 파워볼 하는법

    ReplyDelete
  38. Nice information. I’ve bookmarked your site, and I’m adding your RSS feeds to my Google account to get updates instantly. 경마사이트

    ReplyDelete
  39. I must say you have written a great article. The way you have described everything is phenomenal. If you have time, please visit my site 파친코사이트

    ReplyDelete
  40. Thanks designed for sharing such a pleasant thinking, piece of writing is good, thats why i have read it entirely 스포츠토토

    ReplyDelete
  41. The content is utmost interesting! I have completely enjoyed reading your points and have come to the conclusion that you are right about many of them. You are great, and your efforts are outstanding! nursing test bank

    ReplyDelete
  42. Hey, you used to write wonderful, but the last few posts have been kinda boring¡K I miss your great writings. Past few posts are just a bit out of track! come on! 
    Hasnain

    ReplyDelete
  43. Thanks for the code, however I cannot get the response to send the location. When I do this with curl it works just fine. Any ideas what might be the issue? Thanks!

    ReplyDelete
  44. 바카라사이트
    This is my website and it has been very helpful. How did you come up with this brilliant idea? This is one of the sweetest stories and everyone enjoys it very much. I enjoy visiting many websites.
    You have done a great job. Please visit my website and give your opinion.

    ReplyDelete
  45. This unique seems to be thoroughly ideally suited. Each one of minor essentials are produced alongside large amount of story knowledge. I’m a for the considerably. essential oil boxes

    ReplyDelete
  46. Our Kraft mailer boxes are brilliant if you need strong protection for your items. Don't just settle for the interior looking great.Every single of the materials such as kraft, cardboard, or rigid is sturdy and durable.

    ReplyDelete
  47. Salesforce is a cloud-based software company whose main product is a customer relationship management (CRM) system. A Salesforce developer specializes in using the Lightning and Apex programming languages to design and implement solutions within the context of the Salesforce platform. if anyone wants to learn programming then you can also checkout these free salesforce courses for beginners

    ReplyDelete