We are currently implementing a functionality to automatically create a Box folder upon record creation in Salesforce.
However, we are facing an issue where the folder creation process does not occur (no folder is created, and the return value is NULL) when using the createFolderForRecordId method from the Salesforce Developer Toolkit within an after insert trigger on record creation.
We have confirmed that the process works correctly and the folder is created when manually triggered from the Developer Console.
Could you please provide guidance on the possible cause of this issue? If it is not possible to achieve automatic folder creation within the trigger, could you please suggest an alternative solution for resolving this requirement?
I got a error message as below.
18:18:41:463 USER_DEBUG [572]|DEBUG|Unable to create folder for record id a0E1m000007S0gcEAC - Details: Unable to use default credentials to make a callout to Box (maybe this is in a trigger, constructor, or after a DML statement):
I think there are two potential ways to solve your problem:
If you would like to continue to use an Apex trigger, you will need to use the createFolderForRecordId method call in a separate class. The Box Developer Toolkit leverages future callouts which is why you’re receiving this error.
I think there are two potential ways to solve your problem:
If you would like to continue to use an Apex trigger, you will need to use the createFolderForRecordId method call in a separate class. The Box Developer Toolkit leverages future callouts which is why you’re receiving this error.
I tried separating the class and calling it from the trigger, but I still encountered the same error. Here is my code. Could you please tell me what is wrong with it?
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.