I am trying to call an apex class which returns a list of a wrapper class consisting of contentVersionID, filename, documentID, custom URL, and document_Type__c.

I introduced the LWC component in the screen flow and I am trying to upload files with the help of another LWC component in the sane flow but whenever I am trying to query the details of the existing files corresponding to the current recordId in the middle of screen flow process after uploading the files, I get only those records which were there before uploading the new file. It should be existing records + new uploaded records.

I tried checking it the logs but there were no logs stating that the function getFileNameAndType has been called.

Can anyone help me with this?

    public static string getFileNameAndType(string recordId) {

        System.debug('Function started');
        List < ContentDocumentLink > cdlList = [select id, ContentDocumentId, LinkedEntityId from ContentDocumentLink where LinkedEntityId =: recordId];
        System.debug('cdList :'+cdlList);   
        list < string > ContentDocumentIdList = new list < string > ();
        for (ContentDocumentLink cdl: cdlList) {
        list < ContentVersion > cvList = [select id, Title, ContentDocumentId, Document_Type__c,FileType from ContentVersion where ContentDocumentId In: ContentDocumentIdList and FileType!='SNOTE' order by createdDate DESC];
        System.debug('Final cv '+cvList);
        List < ContentVersionWrapper > contentWrapper = new List < ContentVersionWrapper > ();  

        for (ContentVersion contentIter: cvList) {
            ContentVersionWrapper dataContainer = new ContentVersionWrapper();
            dataContainer.id = contentIter.Id;
            dataContainer.fileName = contentIter.Title;
            dataContainer.documentType = contentIter.Document_Type__c;
            dataContainer.docIds = contentIter.ContentDocumentId;
            dataContainer.url = label.File_Url+ contentIter.ContentDocumentId + '?operationContext=S1';

        System.debug('Wrapper CV '+contentWrapper);
        return JSON.serializePretty(contentWrapper);

I am calling it from LWC component shown below

    connectedCallback() {


    refreshApexData() {
        this.currentRecordId = '8008B0000001wOWQAY';
        console.log('current record Id ' + this.currentRecordId);

        getFileNameAndType({ recordId : '8008B0000001wOWQAY' })        
            results => {
                this.newFileList = results;
                console.log('data to send=' + results);

            errors => {

Flow Diagram enter image description here

  • 1
    The new files will not be in the database unless processed in a separate transaction.
    – Phil W
    Dec 5, 2022 at 13:28


You must log in to answer this question.