Error: The library has not yet been initialized and this call is not allowed
![](https://techprofile.blob.core.windows.net/images/o_3jKzULRUmZCUkaNgbtSw.png?8DCC7E)
I am trying to settings methods as of pages in my application for configuration of urls, to update theme and for multiple functionalities but whenever i am using page.config or getConfig or setConfig. I am always getting this error. because of this error I am not able to work on application. There is no clear solution in google also which can help to resolve.
Please Help me resolve this issue. I found one similar issue but it says by contentUrl in manifest, we can fix but I have no idea how it can be fixed. I tried as per document to create a base URL but still getting the same error.
Microsoft Teams
Microsoft Teams Development
-
Robin Sheng-MSFT • 6,115 Reputation points • Microsoft Vendor
2024-07-01T03:28:05.0033333+00:00 Teams tag is mainly focused on the general issue of Microsoft Teams troubleshooting. According to your description, your question is related to Teams Development which is not in our support scope. To better help you solve your problem, I will add the Teams Development tag to your post. Thanks for your understanding and patience!
-
Deleted
This comment has been deleted due to a violation of our Code of Conduct. The comment was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
-
ShubhamAdmin • 20 Reputation points
2024-07-01T06:31:11.8+00:00 Hi Team,
Here is one of the code which is producing the error mentioned above-app.initialize(); app.getContext().then(() => { pages.config.registerOnSaveHandler( (saveEvent: pages.config.SaveEvent) => { let url = `${sHostname}/${generateUrl}`; let tenantId = window.location.hostname; if (configState.bSSO) { const bydAuth = `${window.location.origin}/sap/ap/ui/${Util.ABAP_PATH}/web/byDTeamsTab/abap/auth.html`; url += `&bydAuth=${encodeURIComponent(bydAuth)}`; } else { tenantId = tenantId.replace("-sso", ""); } pages.config.setConfig({ contentUrl: url, websiteUrl: url, suggestedDisplayName: configState.tabName, removeUrl: `${sHostname}/byDTeamsTab/remove.html?theme={theme}`, entityId: tenantId, }); if (configState.bMandatoryFieldFilled) { saveEvent.notifySuccess(); } else { saveEvent.notifyFailure(); } } ); });
-
Dinesh Rajagoni (Tata Consultancy Services Limi) • 60 Reputation points • Microsoft Vendor
2024-07-02T07:21:26.14+00:00 Hi MOD Administrator - Thanks for raising the query.
We will look into it and let you know the updates.
-
ShubhamAdmin • 20 Reputation points
2024-07-05T10:54:46.85+00:00 Hi @Dinesh Rajagoni (Tata Consultancy Services Limi)
Any update on the issue
-
Dinesh Rajagoni (Tata Consultancy Services Limi) • 60 Reputation points • Microsoft Vendor
2024-07-05T20:02:01.91+00:00 It seems like you're encountering an initialization error with the Microsoft Teams SDK. The error message suggests that the SDK is not properly initialized before calling
setConfig
. Ensure thatapp.initialize()
is called at the start of your app's script execution and that it completes before any other SDK methods are called.Here's a revised version of your code snippet to help illustrate this:
app.initialize().then(() => { // Now that the SDK is initialized, you can use the SDK methods app.getContext().then(() => { pages.config.registerOnSaveHandler((saveEvent) => { // Your existing code logic }); }); }).catch((error) => { // Handle any errors that occur during initialization console.error("Microsoft Teams SDK initialization error:", error); });
Make sure that
app.initialize()
is not nested inside any other function that might delay its execution. It should be one of the first things your app does. If you still encounter issue or have further questions, please let us know. So, we will look into it and let you know the updates. -
Deleted
This comment has been deleted due to a violation of our Code of Conduct. The comment was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
-
ShubhamAdmin • 20 Reputation points
2024-07-08T10:15:46.6566667+00:00 Hi @Dinesh Rajagoni (Tata Consultancy Services Limi)
inside
useEffect
hook,app.initialize()
method can be called?in below code it's being called-
// useEffect(() => { // app.initialize().then(() => { // const contextPromise = app.getContext(); // contextPromise.then((context: app.Context) => { // pages.getConfig().then(() => { // updateTheme(context.app.theme); // Util.switchLanguage(context.app.locale); // // pages.config.setValidityState(true); // app.notifySuccess(); // }); // }); // }); // const sHostname = Util.getQueryVariable("hostname") || ""; // app.initialize().then(() => { // app.getContext().then(() => { // pages.config.registerOnSaveHandler( // (saveEvent: pages.config.SaveEvent) => { // let url = `${sHostname}/${generateUrl}`; // let tenantId = window.location.hostname; // if (configState.bSSO) { // const bydAuth = `${window.location.origin}/sap/ap/ui/${Util.ABAP_PATH}/web/byDTeamsTab/abap/auth.html`; // url += `&bydAuth=${encodeURIComponent(bydAuth)}`; // } else { // tenantId = tenantId.replace("-sso", ""); // } // pages.config.setConfig({ // contentUrl: url, // websiteUrl: url, // suggestedDisplayName: configState.tabName, // removeUrl: `${sHostname}/byDTeamsTab/remove.html?theme={theme}`, // entityId: tenantId, // }); // if (configState.bMandatoryFieldFilled) { // saveEvent.notifySuccess(); // } else { // saveEvent.notifyFailure(); // } // } // ); // }); // }); // });
In Manifest json these are the configurtion in file, any configurations needed to be added -
"icons": { "color": "icon-color.png", "outline": "icon-outline.png" }, "name": { "short": "BYD_Teams_App_Refactor", "full": "Full name for BYD_Teams_App_Refactor" }, "description": { "short": "Collaborate, perform analytics, and sales tasks in Microsoft Teams.", "full": "The SAP Business ByDesign for Microsoft Teams enables users to easily access features of the SAP Business ByDesign system directly from Microsoft Teams. The app caters to the growing need to collaborate across departments and systems while working on the same topic. Using the app, you can collaborate and manage work easily without changing systems, leading to an increase in productivity, and the work getting done effectively. \n\n Key features:\n 1. Access the Business ByDesign system functionalities from the Microsoft Teams app directly.\n 2. Add the different Business Object Work Lists and Business Object Instances on a channel and use the features seamlessly.\n 3. View the Insights Dashboard tab on a channel and view the analytics information for your SAP Business ByDesign solution.\nPrerequisite to use the app is that your company has a running SAP Business ByDesign system and a user which gives you authorization to use certain work centers. If this is not the case you see only the parts for which you are authorized for per default (e.g. Launchpad). Please [get in touch](https://www.sap.com/sea/products/business-bydesign.html/) with your SAP Business ByDesign system administrator to give you the right privileges and system credentials." }, "accentColor": "#FFFFFF", "bots": [], "composeExtensions": [], "configurableTabs": [], "staticTabs": [ { "entityId": "index", "name": "Personal Tab", "scopes": ["personal"] } ], "permissions": ["identity", "messageTeamMembers"],
any of these configuration is the reason for the issue
-
ShubhamAdmin • 20 Reputation points
2024-07-15T04:10:24.7866667+00:00 Hi @Dinesh Rajagoni (Tata Consultancy Services Limi)
Any updates on the issue
-
ShubhamAdmin • 20 Reputation points
2024-07-18T05:58:35.6966667+00:00 Any updates on the issue. any issues on code or manifest files.
-
ShubhamAdmin • 20 Reputation points
2024-07-25T05:11:13.53+00:00 issue is not fixed, tried above solution and kept the code in different code blocks and pages.config.registerOnSaveHandler function is not allowing to use in any other context except settings which is depcricated when we try to use in code
Sign in to comment
1 answer
Sort by: Most helpful
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more