I use a LWC on an opportunity record page to create a pdf document that is then converted to a base64 string. From this a ContentVersion object is created and a ContentDocumentLink from an imperative Apex method call with @AuraEnabled. (To clarify: there is NO manual user upload.)
The pdf document is successfully added to the Opportunity but it does not appear in the related list of "Files" (see image below) or "Notes and Attachment" on the Opportunity record page immediately. A full browser reload is required for the pdf document to show up.
I have tried to run:
const recordId = opportunityRecordId;
getRecordNotifyChange([{recordId}, {recordId: contentVersionId}, {recordId: contentDocumentId}]);
after the creation of the ContentDocumentLink in a then
-block from the apex imperative call but get no result.
I also tried:
const recordId = opportunityRecordId;
updateRecordView(recordId){
updateRecord({fields: {Id: recordId}})
.then(r => {
console.log(r);
})
.catch(err => {
console.error(err);
})
}
in the then
-block but get no result.
I have looked at the AttachedContentDocument object bur from what I see in salesforce doc it does not seem to be a regular object in that sense that it has an Id that can be used as input to for example getRecordNotifyChange()
.
How do I get the "Files" related list to update immediately after creating the ContentDocumentLink?
Any help is much appreciated!
Files not updated/rerendered after creating ContentDocumentLink: