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 = eSELECT 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];
currentFoldero0].box__Record_ID__c = destinationRecordId;
String boxObjectName = currentFoldero0].box__Object_Name__c;
if(boxObjectName == 'Lead'){
currentFoldero0].box__Object_Name__c = 'Opportunity';
} else if(boxObjectName == 'Opportunity'){
currentFoldero0].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.