Perhaps check out the user-agent? It contains Teams/1.5... when loading a site via Teams.
How to check if the SharePoint site is opened from MS teams or not
I have a SharePoint site and added it to Teams as an app , and it works fine. I want to check on a specific page of this site if the page is now running from MS Teams or not . Is it possible to do that with jQuery-JavaScript or is it applicable or not? .
Thank you in advance .
3 answers
Sort by: Newest
-
-
Nivedipa-MSFT 2,806 Reputation points Microsoft Vendor
2022-10-17T09:52:55.817+00:00 @AHMAD ABDELHAFEZ ELAGAMY -
There doesn't seem to be any way available in JQuery/Javascript to check if the SharePoint site is opened from MS teams or notUsing below powershell command you can get the SharePoint site URL and then you can add your custom logic to check if the URL is available in that list or not.
Get-UnifiedGroup –Filter {ResourceProvisioningOptions -eq "Team"} | Select DisplayName,SharePointSiteUrl | Export-CSV ./TeamsSPOUrl.csv -NoTypeInformation
When a team is created, a Microsoft 365 group is created to manage team membership. So, we can use Get-UnifiedGroup cmdlet with ResourceProvisioningOptions filter to retrieve the SharePoint URLs for Teams-enabled Microsoft 365 groups.
The below given code exports Teams and their associated SharePoint site URL to TeamsSPOUrl.csv file.
Get-UnifiedGroup –Filter {ResourceProvisioningOptions -eq "Team"} | Select DisplayName,SharePointSiteUrl | Export-CSV ./TeamsSPOUrl.csv -NoTypeInformation
To run the Get-UnifiedGroup cmdlet, you need to connect to Exchange Online PowerShell module.
Ref Doc: https://learn.microsoft.com/en-us/powershell/module/exchange/get-unifiedgroup?view=exchange-ps
Thanks,
Nivedipa
------------------------------------------------------------------------------------------------------------------------
If the response is helpful, please click "Mark as Best Response" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.
-
JimmySalian-2011 41,921 Reputation points
2022-10-17T07:51:25.913+00:00 Hi,
You can check via the Teams App Usage via the portal - app-usage-report and this is also points to the analytics and reporting teams-reporting-reference
Hope this helps.
JS==
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.