0

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: Files not updated/rerendered after creating ContentDocumentLink

0

There is no alternative $A.get('e.force:refreshView').fire(); in Lightning Web Component which has the capability to refresh the standard component. You need to make use of Aura Component to fire refreshView event whenever you apex execution is done in your lightning web component by firing an event which will be listened by Aura Component.

A sample example is illustrated here:- https://github.com/mitchspano/LWCRefreshDemo

4
  • Alright, thanks! I will try to what you suggest and get back with information on how it went. – Martin Feb 2 at 15:39
  • It worked perfectly, thanks alot! Although I see there is not a license on the code provided in github repo, is it alright to use the code? – Martin Feb 2 at 16:58
  • If you are worried about license, You can have a look on this as well - REFRESH STANDARD COMPONENTS FROM LIGHTNING WEB COMPONENT – sanket kumar Feb 3 at 3:37
  • Will do! Thank you for the help! – Martin Feb 10 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.