pages method is not working in Mircosoft teams-js library

ShubhamAdmin 20 Reputation points
2024-08-13T04:27:15.4933333+00:00

In teams-js library, when i call the pages method for multiple funtionalities like registerOnSaveHandler, getConfig, etc. I am getting error in testing - this call is only allowed in context [setting], current context [content].

I am not able to use the method in any pages in my project. I am using pages method in each page for different functionalities for the application on microsoft teams.

internalAPIs.ts:64 Uncaught (in promise)
Error: This call is only allowed in following contexts: ["settings"]. Current context: "content".
at Tt (internalAPIs.ts:64:1)
at r (pages.ts:545:1)
at e.registerOnSaveHandler (pages.ts:520:1)
at AbapTabConfig.tsx:320:1
Microsoft Teams Development
Microsoft Teams Microsoft Teams for business Other
{count} votes

Accepted answer
  1. Prasad-MSFT 8,981 Reputation points Microsoft External Staff Moderator
    2024-08-29T05:10:14.0133333+00:00

    MOD Administrator, the video you shared shows this code being loaded in a personal static tab:
    User's image

    The registerOnSaveHandler API has never worked there and it makes no sense to be used there because the registered handler is meant to be called when the user clicks on the "Save" button in the Teams UI. There is no Teams-rendered "Save" button for personal static tabs.

    As already mentioned, the registerOnSaveHandler API is built to only work in the tab configuration flow:

    User's image

    It will not work anywhere else.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most 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.