如何在社区页面的弹出窗口中预览文件LWC Salesforce

发布于 2025-02-03 15:38:34 字数 683 浏览 6 评论 0 原文

我一直坚持这些问题,并且不知道如何解决该问题,因此我知道标准库,例如“ navigationmixin”,用于文件预览无法在社区页面中正确工作,因此我

const docId = 'testcontdocid'
this[NavigationMixin.Navigate]({
  type: 'standard__namedPage',
  attributes: {
      pageName: 'filePreview'
  },
  state : {
      selectedRecordId: docId
  }
})

无论如何代码都无法正常工作。找到了一个解决方案,它可以在“ content -Distribution”对象中创建相应的记录,并且在ContentDistribution上的DistributionPublicurl字段自动填充。然后,我可以使用类似的东西:

this[NavigationMixin.Navigate]({
        type: 'standard__webPage',
        attributes: {
            url: DistributionPublicUrl
        }
    });

它可以完美地工作,但是在新的浏览器窗口中打开文件,而不是在弹出窗口中打开文件。有人知道如何解决吗?提前致谢。顺便说一下我使用LWC

I'm stuck to that issues and don't know how to fix that, so As I know standard library such as 'NavigationMixin' for file preview won't correctly work in the community page, so that code won't work

const docId = 'testcontdocid'
this[NavigationMixin.Navigate]({
  type: 'standard__namedPage',
  attributes: {
      pageName: 'filePreview'
  },
  state : {
      selectedRecordId: docId
  }
})

Anyway i found a solution, its to create corresponding record in 'ContentDistribution' object and DistributionPublicUrl field on contentDistribution gets populated automatically. then i can use it something like that:

this[NavigationMixin.Navigate]({
        type: 'standard__webPage',
        attributes: {
            url: DistributionPublicUrl
        }
    });

And it works perfect, but opens the file in the new browser window, not in popup window. Does anyone knows how to fix that? Thanks in advance. By the way i use lwc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

情仇皆在手 2025-02-10 15:38:34

这对我有用,并在社区中展示了预览,并在弹出窗口中所希望的:

        this[NavigationMixin.Navigate]({
            type: 'standard__namedPage',
            attributes: {
                pageName: 'filePreview'
            },
            state : {
                selectedRecordId: file.ContentDocumentId
            }
        })

This worked for me and displayed the preview, in the community, in the pop-up as wished:

        this[NavigationMixin.Navigate]({
            type: 'standard__namedPage',
            attributes: {
                pageName: 'filePreview'
            },
            state : {
                selectedRecordId: file.ContentDocumentId
            }
        })
无畏 2025-02-10 15:38:34

它正在显示弹出

this[NavigationMixin.Navigate](
   {
        type: 'standard__recordPage',
        attributes: {
            recordId: recordId, // pass the record id here.
            actionName: 'edit',
        },
    });

It's showing pop up

this[NavigationMixin.Navigate](
   {
        type: 'standard__recordPage',
        attributes: {
            recordId: recordId, // pass the record id here.
            actionName: 'edit',
        },
    });
长途伴 2025-02-10 15:38:34

在社区中,它将在新窗口中打开
中弹出的方法

`this[NavigationMixin.Navigate]({
    type: 'standard__webPage',
    attributes: {
        url: DistributionPublicUrl
    }
});`

对于此代码,我没有找到与内部salesforce org中显示的同一窗口 社区

 `this[NavigationMixin.Navigate]({
        type: 'standard__namedPage',
        attributes: {
            pageName: 'filePreview'
        },
        state : {
            selectedRecordId: file.ContentDocumentId
        }
    })`
this[NavigationMixin.Navigate]({
        type: 'standard__namedPage',
        attributes: {
            pageName: 'filePreview'
        },
        state : {
            selectedRecordId: file.ContentDocumentId
        }
    })

In the community it will openup in a new window
for this code and i didnt find a way to pop-up in the same window as it shows in the internal salesforce org :(

`this[NavigationMixin.Navigate]({
    type: 'standard__webPage',
    attributes: {
        url: DistributionPublicUrl
    }
});`

and this below approaches we take us to the detail page of contentDocument in the new tab when we try to open in community

 `this[NavigationMixin.Navigate]({
        type: 'standard__namedPage',
        attributes: {
            pageName: 'filePreview'
        },
        state : {
            selectedRecordId: file.ContentDocumentId
        }
    })`
this[NavigationMixin.Navigate]({
        type: 'standard__namedPage',
        attributes: {
            pageName: 'filePreview'
        },
        state : {
            selectedRecordId: file.ContentDocumentId
        }
    })
呆° 2025-02-10 15:38:34

我在社区页面上遇到了类似的问题。而不是使用导航米克林,请尝试使用 Lightning-Modal 组件。

该组件有助于在同一窗口中生成弹出窗口。

参考:

I had faced similar issue with community page. Instead of using NavigationMixin, please try using Lightning-Modal component.

This component helps in generating a pop up in same window.

Refer: https://developer.salesforce.com/docs/component-library/bundle/lightning-modal/documentation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文