Skip to main content
Question

Box Salesforce - Best Practice for Changing Association

  • January 30, 2025
  • 1 reply
  • 12 views

When certain conditions are met, I need to Move a box folder to a different Object and Record ID association. What is the best way to do this? I have access to both the Salesforce SDK and developer toolkit. Should i just update the box_FRUP__c object? I dont see a method for changing association, so it looks like I may need to move the folder to the Opportunity root, then change the FRUP association? I tried this though and BOX doesn’t like it. Maybe I’m doing it wrong.
I have tried a few things but, its not quite working correctly: I call these two methods in a Queueable context method post conversion.

    public static void moveFolder(Id currentRecordId, Id destinationRecordId){
        box.Toolkit toolkit = new box.Toolkit();


        String currentFolderId = getRecordFolder(currentRecordId);
        String destinationObjectId = getObjectFolder(destinationRecordId);

        toolkit.moveFolder(currentFolderId, destinationObjectId, null);
        toolkit.commitChanges();

    }

 

    public static void changeFolderAssociation(Id changeRecordId, Id destinationRecordId){
        String changeFolderId = getRecordFolder(changeRecordId);
        String destinationFolderId = getRecordFolder(destinationRecordId);
        List<box__FRUP__c> currentFolder = [SELECT Id, box__Record_ID__c, box__Folder_ID__c, box__Record_ID_Indexed__c,box__Object_Name__c  FROM box__FRUP__c WHERE box__Folder_ID__c =:changeFolderId];
        currentFolder[0].box__Record_ID__c = destinationRecordId;
        String boxObjectName = currentFolder[0].box__Object_Name__c;
        if(boxObjectName == 'Lead'){
            currentFolder[0].box__Object_Name__c = 'Opportunity';
        } else if(boxObjectName == 'Opportunity'){
            currentFolder[0].box__Object_Name__c = 'Contract Awards';
        }
        upsert currentFolder;
    }



for more description:
A Lead folder is created using the Out of Box toolkit and Box component.
When a client is ready to convert a Lead to an opportunity, I need to move the Lead folder under the Opportunity root and associate it with the new Opportunity record. I also have a custom object to manage the Contract phase of the Sale. So Opportunity will be converted to a Contract Award object and again i want to move the folder and associate it with the new record, so the whole folder moves with the sales process.

 

1 reply

  • Author
  • New Participant
  • 1 reply
  • February 2, 2025

I should mention getRecordFolder is just calling toolkit getFolderIdByRecordId, same for object getObjectFolderByRecordId


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings