Salesforce - Passing folder ID
Hopefully super simple. I have a folder created in Box whenever a custom object record is created. Then I have custom box components (the canvasapp versions of the Box UI elements that Box has put out) that take a folder ID and display the contents or allow uploading to the folder. I'm just trying to find out how to get the ID for that record's folder and pass it into the component. Is it as easy as setting the folder id in the component to a variable and having the page set the variable or something to that effect? If there's already documentation, I would appreciate that as well. I couldn't find anything.
Thanks
-
Official comment
Hi Josh,
There are a few convenience methods built into the Box for Salesforce managed package's dev toolkit to retrieve a Box folder id given a Record.Id:
https://developer.box.com/guides/tooling/salesforce-toolkit/methods/#getfolderidbyrecordid
Another method is to use a SOQL query to get the same details from the box__FRUP__c object:
box__FRUP__c frup = [SELECT box__Folder_ID__c, box__Record_ID__c FROM box__FRUP__c WHERE box__Record_ID__c = :recordId LIMIT 1];
String folderId = frup.box__Folder_ID__c;
System.debug('Found folder with id: ' + folderId);Comment actions -
thank you for that. After about a day of trial and error getting that all set up, I figured out that the apex class that's already installed (I believe with the canvasapp was installed) CanvasAppLifecycleHandler. This seems to do this for us automatically but the folderid field on the component settings needs to be blank. The help text suggested that the default is 0 but when on a record page, the default seems to be the recorded. I think that was out of the box. I don't remember changing anything. Thank you again for your help. You can close this case
Post is closed for comments.
Comments
2 comments