0
votes

I have built a custom Teams app with a static tab pointing to a SharePoint page.

the code for the tab in the app manifest is

        "entityId": "mytab",
        "name": "My Static Tab",
        "contentUrl": "https://TENANT.sharepoint.com/sites/TARGETSITE/_layouts/15/TeamsLogon.aspx?SPFX=true&dest=https%3A%2F%2FTENANT.sharepoint.com%2Fsites%2FTARGETSITE%2FSitePages%2FTARGETPAGE.aspx",
        "websiteUrl": "https://TENANT.sharepoint.com/sites/TARGETSITE/SitePages/TARGETPAGE.aspx",
        "scopes": [
            "personal"
        ]

All is working nice, authentication is done properly.

Now I want to perform some action on the page by deeplinking to the page with some parameter passed as subEntityId and reading the context's subEntityId in an SPFX webpart. According to But unfortunately the value of subEntityId is always undefined.

The deep link would be

https://teams.microsoft.com/_?tenantId=e223420bb-edaf-792a-9dfd-961376a291ae#/apps/35cb66784-343b-4937-8980-9f38c47f737b/mytab?webUrl=https://TENANT.sharepoint.com/sites/TARGETSITE/SitePages/TARGETPAGE.aspx&context=%7B%22subEntityId%22:%20%22MY_PARAMETER_THAT_IS_NOT_PASSED%22%7D

Just linking to the static tab is working fine:

https://teams.microsoft.com/_?tenantId=e223420bb-edaf-792a-9dfd-961376a291ae#/apps/35cb66784-343b-4937-8980-9f38c47f737b/mytab

In both cases the tab is loaded and showing the SharePoint page, Teams-context is properly loaded, but subEntityId is always empty. How can I pass this parameter to my SPFx web part?

1
When you add sub-entity id in the deep-link you will receive the the value of subentity id in tabcontext. Could you please check get context for tab? - Nikitha-MSFT
Hi, subEntityId is already part of the context in deep link as you can see above. Or do I have to put it anywhere else? I have a static tab and no configurable tab where the value could be passed. - ben
I worked on similar lines in past. Let me share what i tried: (1) I created an adpative card. I used deep Link to tab embed into below adaptive Card, which used into power automate to send notification, On click on button, it will navigate to Tab as well as pass parameterize url (2) then consume item id into SPFx webpart like this. SubEntityId used to get the parameterized value, assigned to provided variable: "public componentWillMount() { microsoftTeams.getContext(teamsContext => { this.itemId = teamsContext.subEntityId; }); } " - Dev
That’s pretty much what I need. But subEntityId is always empty. Could you share the urls you used? Both are in the app manifest AND for the deep link containing the context/subEntityId? - ben
Aaw, thats cool @ben. Let me check my code base and see what i can get for you. - Dev

1 Answers

0
votes

Here's what fixed it:

Somehow the generated link including tenant_id is not working properly for deep links with subEntityId

https://teams.microsoft.com/_?tenantId=e223420bb-edaf-792a-9dfd-961376a291ae#/apps/35cb66784-343b-4937-8980-9f38c47f737b/mytab?webUrl=https://TENANT.sharepoint.com/sites/TARGETSITE/SitePages/TARGETPAGE.aspx&context=%7B%22subEntityId%22:%20%22MY_PARAMETER_THAT_IS_NOT_PASSED%22%7D

The following format did the trick an now MYCUSTOMPARAMETERVALUE is properly passed to subEntityId

https://teams.microsoft.com/l/entity/06bc21a9-422f-4dd6-b32d-11820a242651/mytab?context=%7B%22subEntityId%22:%22MYCUSTOMPARAMETERVALUE%22%7D