How to setup the subPageId in teams context

$Yogi$ 0 Reputation points
2024-01-03T09:03:22.59+00:00

I have added below steps in Manifest file but still unable to get the teams subPageId

Accessing subPageId inside context (context.page.subPageId)

Always it's returning the ""

"configurableTabs": [

        {

            "configurationUrl": "<url>",

            "canUpdateConfiguration": true,

            "scopes": [

                "team",

                "groupchat"

            ]

        }

    ],
Microsoft Teams | Microsoft Teams for business | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Om Patil 10 Reputation points
    2024-01-03T09:31:37.99+00:00
    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.

    1. Tab Configuration: In your tab configuration experience (specified by the configurationUrl), make sure you are correctly handling the configuration updates and setting the entityId. This entityId will be the subPageId that you want to access in the Teams context. When a user configures the tab, your configuration page should send the entityId as part of the response back to Teams. The entityId will then be stored and used by Teams as the subPageId in the context.
    2. Accessing subPageId: To access the subPageId in the Teams context, you can use the context.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:
         microsoftTeams.getContext(function (context) {
            var subPageId = context.page.subPageId;
            console.log("SubPageId: " + subPageId);
         });
      
      Ensure that this code is executed when the tab is loaded and the Teams context is available.

    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.

    
    
    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.