How to open a file in the Custom spfx teams tab in MS teams

Copper Contributor

I have created the custom teams Tab using spfx to list all the files in my own desing in the MS teams.In that while clicking the file i need to open a file as same as we open the file in "Files" tab.I tried setting the top url for the page , also many other work around but no luck.

 

so can anyone suggest me how to open the file from the custom SPFX MS Teams tab?

2 Replies

@Admin1925 - To open the sharepoint url with in the teams you need to encode the URL.
Could you please change URL using below code

private string GetFileViewerURL(string actionData_URL, string prefix)
        {
            return $"https://teams.microsoft.com/_#/{prefix}/viewer/teams/" + actionData_URL?.Replace("/", "~2F");
        }
Is there a way to do this in New Teams? This no longer works.