Skip to content

Instantly share code, notes, and snippets.

@Sunil02kumar
Last active February 20, 2017 15:00
Show Gist options
  • Save Sunil02kumar/d91abe92b9b21d2ae8960444299f308e to your computer and use it in GitHub Desktop.
Save Sunil02kumar/d91abe92b9b21d2ae8960444299f308e to your computer and use it in GitHub Desktop.
<apex:page controller="boxFilePickerDemoController">
<html>
<head>
<script type="text/javascript" src="https://app.box.com/js/static/select.js"></script>
</head>
<body>
<!--xxxxxx- Paste Client ID from Box edit application URL -->
<div id="box-select" data-link-type="shared" data-multiselect="true" data-client-id="xxxxxx"></div>
<script>
//Copy Client Id and replace xxxxxx from URL by clicking on edit application in box application
var options = {
clientId: xxxxxx,
linkType: 'shared',
multiselect: 'true'
};
var boxSelect = new BoxSelect(options);
// Register a success callback handler
boxSelect.success(function(response) {
//alert(response);
console.log(response);
var sharedLinks = [];
//Parse shared links from response and store in sharedLinks array
for(var i = 0; i < Object.keys(response).length; i++) {
var obj = response[i];
sharedLinks.push(obj.url);
}
console.log(sharedLinks);
console.log(JSON.stringify(response));
alert(JSON.stringify(response));
//You can pass this JSON to controller method to create atachment in salesforce by using the URL returned in JSON by Box API
});
// Register a cancel callback handler
boxSelect.cancel(function() {
alert('cancel');
});
</script>
</body>
</html>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment