If you are using a configurable tab in Microsoft Teams and you want to access the `subPageId` property in the Teams context, make sure you have configured your tab correctly. Here are the steps to set up and access the `subPageId`:
1. **Manifest File:**
Ensure that you have added the necessary settings in your Microsoft Teams app manifest file. The `subPageId` is typically associated with the `entityId` property. Ensure that your `configurableTabs` section in the manifest includes the `entityId` property:
```json
"configurableTabs": [
{
"configurationUrl": "<url>",
"canUpdateConfiguration": true,
"scopes": [
"team",
"groupchat"
],
"entityId": "yourEntityId"
}
]
Make sure to replace "yourEntityId" with your actual entity ID.
- Tab Configuration:
In your tab configuration experience (specified by the
configurationUrl
), make sure you are correctly handling the configuration updates and setting theentityId
. This entityId will be thesubPageId
that you want to access in the Teams context. When a user configures the tab, your configuration page should send theentityId
as part of the response back to Teams. TheentityId
will then be stored and used by Teams as thesubPageId
in the context. - Accessing
subPageId
: To access thesubPageId
in the Teams context, you can use thecontext.page.subPageId
property. Make sure to access it after the tab has been configured and when the user interacts with the configured tab. Here's an example of how you can access it in your tab:
Ensure that this code is executed when the tab is loaded and the Teams context is available.microsoftTeams.getContext(function (context) { var subPageId = context.page.subPageId; console.log("SubPageId: " + subPageId); });
By following these steps and ensuring that the entityId
is set correctly during tab configuration, you should be able to access the subPageId
property in the Teams context. If you are still facing issues, double-check your manifest file, tab configuration, and the code that accesses the context to ensure everything is set up correctly.